diff src/cmdhist.c @ 31531:6e24001000ed v9.0.1098

patch 9.0.1098: code uses too much indent Commit: https://github.com/vim/vim/commit/465de3a57b815f1188c707e7c083950c81652536 Author: Yegappan Lakshmanan <yegappan@yahoo.com> Date: Mon Dec 26 12:50:04 2022 +0000 patch 9.0.1098: code uses too much indent Problem: Code uses too much indent. Solution: Use an early return. (Yegappan Lakshmanan, closes https://github.com/vim/vim/issues/11747)
author Bram Moolenaar <Bram@vim.org>
date Mon, 26 Dec 2022 14:00:07 +0100
parents a220f176350a
children ca0229869b38
line wrap: on
line diff
--- a/src/cmdhist.c
+++ b/src/cmdhist.c
@@ -460,44 +460,46 @@ del_history_entry(int histype, char_u *s
     int		last;
     int		found = FALSE;
 
-    regmatch.regprog = NULL;
+    if (hislen == 0 || histype < 0 || histype >= HIST_COUNT || *str == NUL
+		|| hisidx[histype] < 0)
+	return FALSE;
+
+    idx = hisidx[histype];
+    regmatch.regprog = vim_regcomp(str, RE_MAGIC + RE_STRING);
+    if (regmatch.regprog == NULL)
+	return FALSE;
+
     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(str, RE_MAGIC + RE_STRING))
-								      != NULL)
+
+    i = last = idx;
+    do
     {
-	i = last = idx;
-	do
+	hisptr = &history[histype][i];
+	if (hisptr->hisstr == NULL)
+	    break;
+	if (vim_regexec(&regmatch, hisptr->hisstr, (colnr_T)0))
 	{
-	    hisptr = &history[histype][i];
-	    if (hisptr->hisstr == NULL)
-		break;
-	    if (vim_regexec(&regmatch, hisptr->hisstr, (colnr_T)0))
+	    found = TRUE;
+	    vim_free(hisptr->hisstr);
+	    clear_hist_entry(hisptr);
+	}
+	else
+	{
+	    if (i != last)
 	    {
-		found = TRUE;
-		vim_free(hisptr->hisstr);
+		history[histype][last] = *hisptr;
 		clear_hist_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 (--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;
 }