To: vim_dev@googlegroups.com Subject: Patch 8.2.4824 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.4824 Problem: Expression is evaluated multiple times. Solution: Evaluate expression once and store the result. (closes #10278) Files: src/map.c *** ../vim-8.2.4823/src/map.c 2022-04-24 18:40:20.791116268 +0100 --- src/map.c 2022-04-25 13:27:30.357053425 +0100 *************** *** 508,513 **** --- 508,514 ---- { int did_it = FALSE; int did_local = FALSE; + int keyround1_simplfied = keyround == 1 && did_simplify; int round; int hash; int new_hash; *************** *** 725,732 **** mpp = &(mp->m_next); continue; } ! if (did_simplify && keyround == 1 ! && !mp->m_simplified) break; // We reset the indicated mode bits. If nothing // is left the entry is deleted below. --- 726,732 ---- mpp = &(mp->m_next); continue; } ! if (keyround1_simplfied && !mp->m_simplified) break; // We reset the indicated mode bits. If nothing // is left the entry is deleted below. *************** *** 779,786 **** mp->m_nowait = nowait; mp->m_silent = silent; mp->m_mode = mode; ! mp->m_simplified = ! did_simplify && keyround == 1; #ifdef FEAT_EVAL mp->m_expr = expr; mp->m_script_ctx = current_sctx; --- 779,785 ---- mp->m_nowait = nowait; mp->m_silent = silent; mp->m_mode = mode; ! mp->m_simplified = keyround1_simplfied; #ifdef FEAT_EVAL mp->m_expr = expr; mp->m_script_ctx = current_sctx; *************** *** 818,824 **** // delete entry if (!did_it) { ! if (!did_simplify || keyround == 2) retval = 2; // no match } else if (*keys == Ctrl_C) --- 817,823 ---- // delete entry if (!did_it) { ! if (!keyround1_simplfied) retval = 2; // no match } else if (*keys == Ctrl_C) *************** *** 854,860 **** #ifdef FEAT_EVAL expr, /* sid */ -1, /* scriptversion */ 0, /* lnum */ 0, #endif ! did_simplify && keyround == 1) == FAIL) { retval = 4; // no mem goto theend; --- 853,859 ---- #ifdef FEAT_EVAL expr, /* sid */ -1, /* scriptversion */ 0, /* lnum */ 0, #endif ! keyround1_simplfied) == FAIL) { retval = 4; // no mem goto theend; *** ../vim-8.2.4823/src/version.c 2022-04-25 12:43:15.179819208 +0100 --- src/version.c 2022-04-25 13:26:19.909107985 +0100 *************** *** 748,749 **** --- 748,751 ---- { /* Add new patch number below this line */ + /**/ + 4824, /**/ -- There is a difference between "should work" and "does work", it's called testing. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// \\\ \\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///