From dc4daa3a3915fba11ac87d27977240d9a5e0d47d Mon Sep 17 00:00:00 2001 From: Yegappan Lakshmanan Date: Mon, 2 Jan 2023 16:54:53 +0000 Subject: patch 9.0.1132: code is indented more than needed Problem: Code is indented more than needed. Solution: Use an early return to reduce indentation. (Yegappan Lakshmanan, closes #11769) --- src/evalwindow.c | 102 +++++++++++++++++++++++++++---------------------------- 1 file changed, 51 insertions(+), 51 deletions(-) (limited to 'src/evalwindow.c') diff --git a/src/evalwindow.c b/src/evalwindow.c index f8c0c7acfd..8b47b98fd1 100644 --- a/src/evalwindow.c +++ b/src/evalwindow.c @@ -718,66 +718,66 @@ f_win_execute(typval_T *argvars, typval_T *rettv) id = (int)tv_get_number(argvars); wp = win_id2wp_tp(id, &tp); - if (wp != NULL && tp != NULL) - { - pos_T curpos = wp->w_cursor; - char_u cwd[MAXPATHL]; - int cwd_status = FAIL; + if (wp == NULL || tp == NULL) + return; + + pos_T curpos = wp->w_cursor; + char_u cwd[MAXPATHL]; + int cwd_status = FAIL; #ifdef FEAT_AUTOCHDIR - char_u autocwd[MAXPATHL]; - int apply_acd = FALSE; + char_u autocwd[MAXPATHL]; + int apply_acd = FALSE; #endif - // Getting and setting directory can be slow on some systems, only do - // this when the current or target window/tab have a local directory or - // 'acd' is set. - if (curwin != wp - && (curwin->w_localdir != NULL - || wp->w_localdir != NULL - || (curtab != tp - && (curtab->tp_localdir != NULL - || tp->tp_localdir != NULL)) + // Getting and setting directory can be slow on some systems, only do + // this when the current or target window/tab have a local directory or + // 'acd' is set. + if (curwin != wp + && (curwin->w_localdir != NULL + || wp->w_localdir != NULL + || (curtab != tp + && (curtab->tp_localdir != NULL + || tp->tp_localdir != NULL)) #ifdef FEAT_AUTOCHDIR - || p_acd + || p_acd #endif - )) - cwd_status = mch_dirname(cwd, MAXPATHL); + )) + cwd_status = mch_dirname(cwd, MAXPATHL); #ifdef FEAT_AUTOCHDIR - // If 'acd' is set, check we are using that directory. If yes, then - // apply 'acd' afterwards, otherwise restore the current directory. - if (cwd_status == OK && p_acd) - { - do_autochdir(); - apply_acd = mch_dirname(autocwd, MAXPATHL) == OK - && STRCMP(cwd, autocwd) == 0; - } + // If 'acd' is set, check we are using that directory. If yes, then + // apply 'acd' afterwards, otherwise restore the current directory. + if (cwd_status == OK && p_acd) + { + do_autochdir(); + apply_acd = mch_dirname(autocwd, MAXPATHL) == OK + && STRCMP(cwd, autocwd) == 0; + } #endif - if (switch_win_noblock(&switchwin, wp, tp, TRUE) == OK) - { - check_cursor(); - execute_common(argvars, rettv, 1); - } - restore_win_noblock(&switchwin, TRUE); + if (switch_win_noblock(&switchwin, wp, tp, TRUE) == OK) + { + check_cursor(); + execute_common(argvars, rettv, 1); + } + restore_win_noblock(&switchwin, TRUE); #ifdef FEAT_AUTOCHDIR - if (apply_acd) - do_autochdir(); - else + if (apply_acd) + do_autochdir(); + else #endif - if (cwd_status == OK) + if (cwd_status == OK) mch_chdir((char *)cwd); - // Update the status line if the cursor moved. - if (win_valid(wp) && !EQUAL_POS(curpos, wp->w_cursor)) - wp->w_redr_status = TRUE; + // Update the status line if the cursor moved. + if (win_valid(wp) && !EQUAL_POS(curpos, wp->w_cursor)) + wp->w_redr_status = TRUE; - // In case the command moved the cursor or changed the Visual area, - // check it is valid. - check_cursor(); - if (VIsual_active) - check_pos(curbuf, &VIsual); - } + // In case the command moved the cursor or changed the Visual area, + // check it is valid. + check_cursor(); + if (VIsual_active) + check_pos(curbuf, &VIsual); } /* @@ -1093,11 +1093,11 @@ f_getcmdwintype(typval_T *argvars UNUSED, typval_T *rettv) rettv->v_type = VAR_STRING; rettv->vval.v_string = NULL; rettv->vval.v_string = alloc(2); - if (rettv->vval.v_string != NULL) - { - rettv->vval.v_string[0] = cmdwin_type; - rettv->vval.v_string[1] = NUL; - } + if (rettv->vval.v_string == NULL) + return; + + rettv->vval.v_string[0] = cmdwin_type; + rettv->vval.v_string[1] = NUL; } /* -- cgit v1.2.3