diff options
author | Felipe Oliveira Carvalho <felipekde@gmail.com> | 2014-12-13 10:55:51 -0300 |
---|---|---|
committer | Felipe Oliveira Carvalho <felipekde@gmail.com> | 2014-12-13 23:36:11 -0300 |
commit | 77135447e09903b45d1482da45869946212f7904 (patch) | |
tree | 53b17c11d4bfbe8031842cfb65ae5c53c5eb41d7 /src/nvim/eval.c | |
parent | 64a32d55c59188f1e922ca438fdb2d65caa06665 (diff) | |
download | rneovim-77135447e09903b45d1482da45869946212f7904.tar.gz rneovim-77135447e09903b45d1482da45869946212f7904.tar.bz2 rneovim-77135447e09903b45d1482da45869946212f7904.zip |
Reduce indentation level by early returning or continuing loop
Replace code like this
```c
func() {
if (cond) {
...
...
...
}
return ret;
}
```
```c
for (...) {
if (cond) {
...
...
...
}
}
```
with
```c
func() {
if (!cond) {
return ret;
}
...
...
...
}
```
```c
for (...) {
if (!cond) {
continue;
}
...
...
...
}
```
Diffstat (limited to 'src/nvim/eval.c')
-rw-r--r-- | src/nvim/eval.c | 39 |
1 files changed, 20 insertions, 19 deletions
diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 45ab901398..71cb83e566 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -5987,29 +5987,30 @@ static char_u *dict2string(typval_T *tv, int copyID) todo = (int)d->dv_hashtab.ht_used; for (hi = d->dv_hashtab.ht_array; todo > 0 && !got_int; ++hi) { - if (!HASHITEM_EMPTY(hi)) { - --todo; + if (HASHITEM_EMPTY(hi)) { + continue; + } + --todo; - if (first) - first = FALSE; - else - ga_concat(&ga, (char_u *)", "); + if (first) + first = FALSE; + else + ga_concat(&ga, (char_u *)", "); - tofree = string_quote(hi->hi_key, FALSE); - if (tofree != NULL) { - ga_concat(&ga, tofree); - free(tofree); - } - ga_concat(&ga, (char_u *)": "); - s = tv2string(&HI2DI(hi)->di_tv, &tofree, numbuf, copyID); - if (s != NULL) - ga_concat(&ga, s); + tofree = string_quote(hi->hi_key, FALSE); + if (tofree != NULL) { + ga_concat(&ga, tofree); free(tofree); - if (s == NULL || did_echo_string_emsg) { - break; - } - line_breakcheck(); } + ga_concat(&ga, (char_u *)": "); + s = tv2string(&HI2DI(hi)->di_tv, &tofree, numbuf, copyID); + if (s != NULL) + ga_concat(&ga, s); + free(tofree); + if (s == NULL || did_echo_string_emsg) { + break; + } + line_breakcheck(); } if (todo > 0) { free(ga.ga_data); |