From a41e221935edab62672a15123af48f4f14ac1c7d Mon Sep 17 00:00:00 2001 From: Yegappan Lakshmanan Date: Mon, 16 Jan 2023 18:19:05 +0000 Subject: patch 9.0.1208: code is indented more than necessary Problem: Code is indented more than necessary. Solution: Use an early return where it makes sense. (Yegappan Lakshmanan, closes #11819) --- src/ops.c | 51 ++++++++++++++++++++++++++------------------------- 1 file changed, 26 insertions(+), 25 deletions(-) (limited to 'src/ops.c') diff --git a/src/ops.c b/src/ops.c index bd927860e..f4059b86f 100644 --- a/src/ops.c +++ b/src/ops.c @@ -989,11 +989,11 @@ mb_adjust_opend(oparg_T *oap) { char_u *p; - if (oap->inclusive) - { - p = ml_get(oap->end.lnum); - oap->end.col += mb_tail_off(p, p + oap->end.col); - } + if (!oap->inclusive) + return; + + p = ml_get(oap->end.lnum); + oap->end.col += mb_tail_off(p, p + oap->end.col); } /* @@ -1869,22 +1869,23 @@ adjust_cursor_eol(void) { unsigned int cur_ve_flags = get_ve_flags(); - if (curwin->w_cursor.col > 0 - && gchar_cursor() == NUL - && (cur_ve_flags & VE_ONEMORE) == 0 - && !(restart_edit || (State & MODE_INSERT))) - { - // Put the cursor on the last character in the line. - dec_cursor(); + int adj_cursor = (curwin->w_cursor.col > 0 + && gchar_cursor() == NUL + && (cur_ve_flags & VE_ONEMORE) == 0 + && !(restart_edit || (State & MODE_INSERT))); + if (!adj_cursor) + return; - if (cur_ve_flags == VE_ALL) - { - colnr_T scol, ecol; + // Put the cursor on the last character in the line. + dec_cursor(); - // Coladd is set to the width of the last character. - getvcol(curwin, &curwin->w_cursor, &scol, NULL, &ecol); - curwin->w_cursor.coladd = ecol - scol + 1; - } + if (cur_ve_flags == VE_ALL) + { + colnr_T scol, ecol; + + // Coladd is set to the width of the last character. + getvcol(curwin, &curwin->w_cursor, &scol, NULL, &ecol); + curwin->w_cursor.coladd = ecol - scol + 1; } } @@ -2235,12 +2236,12 @@ reset_lbr(void) static void restore_lbr(int lbr_saved) { - if (!curwin->w_p_lbr && lbr_saved) - { - // changing 'linebreak' may require w_virtcol to be updated - curwin->w_p_lbr = TRUE; - curwin->w_valid &= ~(VALID_WROW|VALID_WCOL|VALID_VIRTCOL); - } + if (curwin->w_p_lbr || !lbr_saved) + return; + + // changing 'linebreak' may require w_virtcol to be updated + curwin->w_p_lbr = TRUE; + curwin->w_valid &= ~(VALID_WROW|VALID_WCOL|VALID_VIRTCOL); } #endif -- cgit v1.2.1