vim-patch:9.0.1098: code uses too much indent (#21540)

Problem:    Code uses too much indent.
Solution:   Use an early return. (Yegappan Lakshmanan, closes vim/vim#11747)

465de3a57b

Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
This commit is contained in:
zeertzjq
2022-12-26 21:54:31 +08:00
committed by GitHub
parent 94ce25065b
commit 738427d498
4 changed files with 181 additions and 170 deletions

View File

@@ -439,24 +439,24 @@ int clr_history(const int histype)
/// @param histype may be one of the HIST_ values.
static int del_history_entry(int histype, char_u *str)
{
regmatch_T regmatch;
histentry_T *hisptr;
int idx;
int i;
int last;
bool found = false;
if (hislen == 0 || histype < 0 || histype >= HIST_COUNT || *str == NUL
|| hisidx[histype] < 0) {
return false;
}
const int idx = hisidx[histype];
regmatch_T regmatch;
regmatch.regprog = vim_regcomp((char *)str, RE_MAGIC + RE_STRING);
if (regmatch.regprog == NULL) {
return false;
}
regmatch.regprog = NULL;
regmatch.rm_ic = false; // always match case
if (hislen != 0
&& histype >= 0
&& histype < HIST_COUNT
&& *str != NUL
&& (idx = hisidx[histype]) >= 0
&& (regmatch.regprog = vim_regcomp((char *)str, RE_MAGIC + RE_STRING)) != NULL) {
i = last = idx;
bool found = false;
int i = idx, last = idx;
do {
hisptr = &history[histype][i];
histentry_T *hisptr = &history[histype][i];
if (hisptr->hisstr == NULL) {
break;
}
@@ -476,10 +476,11 @@ static int del_history_entry(int histype, char_u *str)
i += hislen;
}
} while (i != idx);
if (history[histype][idx].hisstr == NULL) {
hisidx[histype] = -1;
}
}
vim_regfree(regmatch.regprog);
return found;
}

View File

@@ -594,7 +594,10 @@ void ex_breakadd(exarg_T *eap)
gap = &prof_ga;
}
if (dbg_parsearg(eap->arg, gap) == OK) {
if (dbg_parsearg(eap->arg, gap) != OK) {
return;
}
struct debuggy *bp = &DEBUGGY(gap, gap->ga_len);
bp->dbg_forceit = eap->forceit;
@@ -622,7 +625,6 @@ void ex_breakadd(exarg_T *eap)
debug_tick++;
}
}
}
/// ":debuggreedy".
void ex_debuggreedy(exarg_T *eap)
@@ -682,7 +684,9 @@ void ex_breakdel(exarg_T *eap)
if (todel < 0) {
semsg(_("E161: Breakpoint not found: %s"), eap->arg);
} else {
return;
}
while (!GA_EMPTY(gap)) {
xfree(DEBUGGY(gap, todel).dbg_name);
if (DEBUGGY(gap, todel).dbg_type == DBG_EXPR
@@ -708,14 +712,15 @@ void ex_breakdel(exarg_T *eap)
ga_clear(gap);
}
}
}
/// ":breaklist".
void ex_breaklist(exarg_T *eap)
{
if (GA_EMPTY(&dbg_breakp)) {
msg(_("No breakpoints defined"));
} else {
return;
}
for (int i = 0; i < dbg_breakp.ga_len; i++) {
struct debuggy *bp = &BREAKP(i);
if (bp->dbg_type == DBG_FILE) {
@@ -732,7 +737,6 @@ void ex_breaklist(exarg_T *eap)
}
}
}
}
/// Find a breakpoint for a function or sourced file.
/// Returns line number at which to break; zero when no matching breakpoint.

View File

@@ -1147,6 +1147,7 @@ static int diff_file(diffio_T *dio)
if (dio->dio_internal) {
return diff_file_internal(dio);
}
const size_t len = (strlen(tmp_orig) + strlen(tmp_new) + strlen(tmp_diff)
+ strlen(p_srr) + 27);
char *const cmd = xmalloc(len);
@@ -1350,14 +1351,19 @@ void ex_diffsplit(exarg_T *eap)
// don't use a new tab page, each tab page has its own diffs
cmdmod.cmod_tab = 0;
if (win_split(0, (diff_flags & DIFF_VERTICAL) ? WSP_VERT : 0) != FAIL) {
if (win_split(0, (diff_flags & DIFF_VERTICAL) ? WSP_VERT : 0) == FAIL) {
return;
}
// Pretend it was a ":split fname" command
eap->cmdidx = CMD_split;
curwin->w_p_diff = true;
do_exedit(eap, old_curwin);
// split must have worked
if (curwin != old_curwin) {
if (curwin == old_curwin) { // split didn't work
return;
}
// Set 'diff', 'scrollbind' on and 'wrap' off.
diff_win_options(curwin, true);
if (win_valid(old_curwin)) {
@@ -1373,8 +1379,6 @@ void ex_diffsplit(exarg_T *eap)
// relative position.
scroll_to_fraction(curwin, curwin->w_height);
}
}
}
// Set options to show diffs for the current window.
void ex_diffthis(exarg_T *eap)

View File

@@ -1826,7 +1826,10 @@ static void printdigraph(const digr_T *dp, result_T *previous)
char_u buf[30];
int list_width = 13;
if (dp->result != 0) {
if (dp->result == 0) {
return;
}
if (previous != NULL) {
for (int i = 0; header_table[i].dg_header != NULL; i++) {
if (*previous < header_table[i].dg_start
@@ -1874,7 +1877,6 @@ static void printdigraph(const digr_T *dp, result_T *previous)
vim_snprintf((char *)p, sizeof(buf) - (size_t)(p - buf), " %3d", dp->result);
msg_outtrans((char *)buf);
}
}
/// Get the two digraph characters from a typval.
/// @return OK or FAIL.