Mercurial > vim
changeset 28600:17251b82b69a v8.2.4824
patch 8.2.4824: expression is evaluated multiple times
Commit: https://github.com/vim/vim/commit/23d5770ef5e2f5c6d20d123303b81327045e5a1e
Author: zeertzjq <zeertzjq@outlook.com>
Date: Mon Apr 25 13:28:00 2022 +0100
patch 8.2.4824: expression is evaluated multiple times
Problem: Expression is evaluated multiple times.
Solution: Evaluate expression once and store the result. (closes https://github.com/vim/vim/issues/10278)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Mon, 25 Apr 2022 14:30:03 +0200 |
parents | 21b38da3ec22 |
children | a4d54a260c59 |
files | src/map.c src/version.c |
diffstat | 2 files changed, 7 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/src/map.c +++ b/src/map.c @@ -508,6 +508,7 @@ do_map( { int did_it = FALSE; int did_local = FALSE; + int keyround1_simplfied = keyround == 1 && did_simplify; int round; int hash; int new_hash; @@ -725,8 +726,7 @@ do_map( mpp = &(mp->m_next); continue; } - if (did_simplify && keyround == 1 - && !mp->m_simplified) + if (keyround1_simplfied && !mp->m_simplified) break; // We reset the indicated mode bits. If nothing // is left the entry is deleted below. @@ -779,8 +779,7 @@ do_map( mp->m_nowait = nowait; mp->m_silent = silent; mp->m_mode = mode; - mp->m_simplified = - did_simplify && keyround == 1; + mp->m_simplified = keyround1_simplfied; #ifdef FEAT_EVAL mp->m_expr = expr; mp->m_script_ctx = current_sctx; @@ -818,7 +817,7 @@ do_map( // delete entry if (!did_it) { - if (!did_simplify || keyround == 2) + if (!keyround1_simplfied) retval = 2; // no match } else if (*keys == Ctrl_C) @@ -854,7 +853,7 @@ do_map( #ifdef FEAT_EVAL expr, /* sid */ -1, /* scriptversion */ 0, /* lnum */ 0, #endif - did_simplify && keyround == 1) == FAIL) + keyround1_simplfied) == FAIL) { retval = 4; // no mem goto theend;