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/normal.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/normal.c')
| -rw-r--r-- | src/nvim/normal.c | 65 |
1 files changed, 33 insertions, 32 deletions
diff --git a/src/nvim/normal.c b/src/nvim/normal.c index 3b4d4047db..7a2cd686c6 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -3124,40 +3124,41 @@ void check_scrollbind(linenr_T topline_diff, long leftcol_diff) for (curwin = firstwin; curwin; curwin = curwin->w_next) { curbuf = curwin->w_buffer; /* skip original window and windows with 'noscrollbind' */ - if (curwin != old_curwin && curwin->w_p_scb) { - /* - * do the vertical scroll - */ - if (want_ver) { - if (old_curwin->w_p_diff && curwin->w_p_diff) { - diff_set_topline(old_curwin, curwin); - } else { - curwin->w_scbind_pos += topline_diff; - topline = curwin->w_scbind_pos; - if (topline > curbuf->b_ml.ml_line_count) - topline = curbuf->b_ml.ml_line_count; - if (topline < 1) - topline = 1; - - y = topline - curwin->w_topline; - if (y > 0) - scrollup(y, false); - else - scrolldown(-y, false); - } - - redraw_later(VALID); - cursor_correct(); - curwin->w_redr_status = true; + if (curwin == old_curwin || !curwin->w_p_scb) { + continue; + } + /* + * do the vertical scroll + */ + if (want_ver) { + if (old_curwin->w_p_diff && curwin->w_p_diff) { + diff_set_topline(old_curwin, curwin); + } else { + curwin->w_scbind_pos += topline_diff; + topline = curwin->w_scbind_pos; + if (topline > curbuf->b_ml.ml_line_count) + topline = curbuf->b_ml.ml_line_count; + if (topline < 1) + topline = 1; + + y = topline - curwin->w_topline; + if (y > 0) + scrollup(y, false); + else + scrolldown(-y, false); } - /* - * do the horizontal scroll - */ - if (want_hor && curwin->w_leftcol != tgt_leftcol) { - curwin->w_leftcol = tgt_leftcol; - leftcol_changed(); - } + redraw_later(VALID); + cursor_correct(); + curwin->w_redr_status = true; + } + + /* + * do the horizontal scroll + */ + if (want_hor && curwin->w_leftcol != tgt_leftcol) { + curwin->w_leftcol = tgt_leftcol; + leftcol_changed(); } } |