patch 9.0.1221: 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 #11833)
diff --git a/src/regexp.c b/src/regexp.c
index af8b375..f18f33d 100644
--- a/src/regexp.c
+++ b/src/regexp.c
@@ -710,10 +710,11 @@
{
static int after_slash = FALSE;
- if (curchr == -1)
+ if (curchr != -1)
+ return curchr;
+
+ switch (curchr = regparse[0])
{
- switch (curchr = regparse[0])
- {
case '.':
case '[':
case '~':
@@ -743,7 +744,7 @@
case ';': // future ext.
case '`': // future ext.
case '/': // Can't be used in / command
- // magic only after "\v"
+ // magic only after "\v"
if (reg_magic == MAGIC_ALL)
curchr = Magic(curchr);
break;
@@ -788,8 +789,8 @@
// ignore \c \C \m \M \v \V and \Z after '$'
while (p[0] == '\\' && (p[1] == 'c' || p[1] == 'C'
- || p[1] == 'm' || p[1] == 'M'
- || p[1] == 'v' || p[1] == 'V' || p[1] == 'Z'))
+ || p[1] == 'm' || p[1] == 'M'
+ || p[1] == 'v' || p[1] == 'V' || p[1] == 'Z'))
{
if (p[1] == 'v')
is_magic_all = TRUE;
@@ -802,7 +803,7 @@
&& (p[1] == '|' || p[1] == '&' || p[1] == ')'
|| p[1] == 'n'))
|| (is_magic_all
- && (p[0] == '|' || p[0] == '&' || p[0] == ')'))
+ && (p[0] == '|' || p[0] == '&' || p[0] == ')'))
|| reg_magic == MAGIC_ALL)
curchr = Magic('$');
}
@@ -858,7 +859,6 @@
default:
if (has_mbyte)
curchr = (*mb_ptr2char)(regparse);
- }
}
return curchr;
@@ -1384,42 +1384,42 @@
static void
cleanup_subexpr(void)
{
- if (rex.need_clear_subexpr)
+ if (!rex.need_clear_subexpr)
+ return;
+
+ if (REG_MULTI)
{
- if (REG_MULTI)
- {
- // Use 0xff to set lnum to -1
- vim_memset(rex.reg_startpos, 0xff, sizeof(lpos_T) * NSUBEXP);
- vim_memset(rex.reg_endpos, 0xff, sizeof(lpos_T) * NSUBEXP);
- }
- else
- {
- vim_memset(rex.reg_startp, 0, sizeof(char_u *) * NSUBEXP);
- vim_memset(rex.reg_endp, 0, sizeof(char_u *) * NSUBEXP);
- }
- rex.need_clear_subexpr = FALSE;
+ // Use 0xff to set lnum to -1
+ vim_memset(rex.reg_startpos, 0xff, sizeof(lpos_T) * NSUBEXP);
+ vim_memset(rex.reg_endpos, 0xff, sizeof(lpos_T) * NSUBEXP);
}
+ else
+ {
+ vim_memset(rex.reg_startp, 0, sizeof(char_u *) * NSUBEXP);
+ vim_memset(rex.reg_endp, 0, sizeof(char_u *) * NSUBEXP);
+ }
+ rex.need_clear_subexpr = FALSE;
}
#ifdef FEAT_SYN_HL
static void
cleanup_zsubexpr(void)
{
- if (rex.need_clear_zsubexpr)
+ if (!rex.need_clear_zsubexpr)
+ return;
+
+ if (REG_MULTI)
{
- if (REG_MULTI)
- {
- // Use 0xff to set lnum to -1
- vim_memset(reg_startzpos, 0xff, sizeof(lpos_T) * NSUBEXP);
- vim_memset(reg_endzpos, 0xff, sizeof(lpos_T) * NSUBEXP);
- }
- else
- {
- vim_memset(reg_startzp, 0, sizeof(char_u *) * NSUBEXP);
- vim_memset(reg_endzp, 0, sizeof(char_u *) * NSUBEXP);
- }
- rex.need_clear_zsubexpr = FALSE;
+ // Use 0xff to set lnum to -1
+ vim_memset(reg_startzpos, 0xff, sizeof(lpos_T) * NSUBEXP);
+ vim_memset(reg_endzpos, 0xff, sizeof(lpos_T) * NSUBEXP);
}
+ else
+ {
+ vim_memset(reg_startzp, 0, sizeof(char_u *) * NSUBEXP);
+ vim_memset(reg_endzp, 0, sizeof(char_u *) * NSUBEXP);
+ }
+ rex.need_clear_zsubexpr = FALSE;
}
#endif