patch 8.2.4824: expression is evaluated multiple times

Problem:    Expression is evaluated multiple times.
Solution:   Evaluate expression once and store the result. (closes #10278)
This commit is contained in:
zeertzjq
2022-04-25 13:28:00 +01:00
committed by Bram Moolenaar
parent 372bcceeee
commit 23d5770ef5
2 changed files with 7 additions and 6 deletions

View File

@ -508,6 +508,7 @@ do_map(
{ {
int did_it = FALSE; int did_it = FALSE;
int did_local = FALSE; int did_local = FALSE;
int keyround1_simplfied = keyround == 1 && did_simplify;
int round; int round;
int hash; int hash;
int new_hash; int new_hash;
@ -725,8 +726,7 @@ do_map(
mpp = &(mp->m_next); mpp = &(mp->m_next);
continue; continue;
} }
if (did_simplify && keyround == 1 if (keyround1_simplfied && !mp->m_simplified)
&& !mp->m_simplified)
break; break;
// We reset the indicated mode bits. If nothing // We reset the indicated mode bits. If nothing
// is left the entry is deleted below. // is left the entry is deleted below.
@ -779,8 +779,7 @@ do_map(
mp->m_nowait = nowait; mp->m_nowait = nowait;
mp->m_silent = silent; mp->m_silent = silent;
mp->m_mode = mode; mp->m_mode = mode;
mp->m_simplified = mp->m_simplified = keyround1_simplfied;
did_simplify && keyround == 1;
#ifdef FEAT_EVAL #ifdef FEAT_EVAL
mp->m_expr = expr; mp->m_expr = expr;
mp->m_script_ctx = current_sctx; mp->m_script_ctx = current_sctx;
@ -818,7 +817,7 @@ do_map(
// delete entry // delete entry
if (!did_it) if (!did_it)
{ {
if (!did_simplify || keyround == 2) if (!keyround1_simplfied)
retval = 2; // no match retval = 2; // no match
} }
else if (*keys == Ctrl_C) else if (*keys == Ctrl_C)
@ -854,7 +853,7 @@ do_map(
#ifdef FEAT_EVAL #ifdef FEAT_EVAL
expr, /* sid */ -1, /* scriptversion */ 0, /* lnum */ 0, expr, /* sid */ -1, /* scriptversion */ 0, /* lnum */ 0,
#endif #endif
did_simplify && keyround == 1) == FAIL) keyround1_simplfied) == FAIL)
{ {
retval = 4; // no mem retval = 4; // no mem
goto theend; goto theend;

View File

@ -746,6 +746,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
4824,
/**/ /**/
4823, 4823,
/**/ /**/