aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/diff.c
diff options
context:
space:
mode:
authorFelipe Oliveira Carvalho <felipekde@gmail.com>2014-12-13 10:55:51 -0300
committerFelipe Oliveira Carvalho <felipekde@gmail.com>2014-12-13 23:36:11 -0300
commit77135447e09903b45d1482da45869946212f7904 (patch)
tree53b17c11d4bfbe8031842cfb65ae5c53c5eb41d7 /src/nvim/diff.c
parent64a32d55c59188f1e922ca438fdb2d65caa06665 (diff)
downloadrneovim-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/diff.c')
-rw-r--r--src/nvim/diff.c31
1 files changed, 16 insertions, 15 deletions
diff --git a/src/nvim/diff.c b/src/nvim/diff.c
index b557753bff..3151daf826 100644
--- a/src/nvim/diff.c
+++ b/src/nvim/diff.c
@@ -579,24 +579,25 @@ static int diff_check_sanity(tabpage_T *tp, diff_T *dp)
static void diff_redraw(int dofold)
{
FOR_ALL_WINDOWS_IN_TAB(wp, curtab) {
- if (wp->w_p_diff) {
- redraw_win_later(wp, SOME_VALID);
- if (dofold && foldmethodIsDiff(wp)) {
- foldUpdateAll(wp);
- }
+ if (!wp->w_p_diff) {
+ continue;
+ }
+ redraw_win_later(wp, SOME_VALID);
+ if (dofold && foldmethodIsDiff(wp)) {
+ foldUpdateAll(wp);
+ }
- /* A change may have made filler lines invalid, need to take care
- * of that for other windows. */
- int n = diff_check(wp, wp->w_topline);
+ /* A change may have made filler lines invalid, need to take care
+ * of that for other windows. */
+ int n = diff_check(wp, wp->w_topline);
- if (((wp != curwin) && (wp->w_topfill > 0)) || (n > 0)) {
- if (wp->w_topfill > n) {
- wp->w_topfill = (n < 0 ? 0 : n);
- } else if ((n > 0) && (n > wp->w_topfill)) {
- wp->w_topfill = n;
- }
- check_topfill(wp, FALSE);
+ if (((wp != curwin) && (wp->w_topfill > 0)) || (n > 0)) {
+ if (wp->w_topfill > n) {
+ wp->w_topfill = (n < 0 ? 0 : n);
+ } else if ((n > 0) && (n > wp->w_topfill)) {
+ wp->w_topfill = n;
}
+ check_topfill(wp, FALSE);
}
}
}