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,47 +439,48 @@ 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;
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;
do {
hisptr = &history[histype][i];
if (hisptr->hisstr == NULL) {
break;
}
if (vim_regexec(&regmatch, hisptr->hisstr, (colnr_T)0)) {
found = true;
hist_free_entry(hisptr);
} else {
if (i != last) {
history[histype][last] = *hisptr;
clear_hist_entry(hisptr);
}
if (--last < 0) {
last += hislen;
}
}
if (--i < 0) {
i += hislen;
}
} while (i != idx);
if (history[histype][idx].hisstr == NULL) {
hisidx[histype] = -1;
}
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.rm_ic = false; // always match case
bool found = false;
int i = idx, last = idx;
do {
histentry_T *hisptr = &history[histype][i];
if (hisptr->hisstr == NULL) {
break;
}
if (vim_regexec(&regmatch, hisptr->hisstr, (colnr_T)0)) {
found = true;
hist_free_entry(hisptr);
} else {
if (i != last) {
history[histype][last] = *hisptr;
clear_hist_entry(hisptr);
}
if (--last < 0) {
last += hislen;
}
}
if (--i < 0) {
i += hislen;
}
} while (i != idx);
if (history[histype][idx].hisstr == NULL) {
hisidx[histype] = -1;
}
vim_regfree(regmatch.regprog);
return found;
}