]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.2.0754: repeated completion length lookup in search_for_exact_line v9.2.0754
authorglepnir <glephunter@gmail.com>
Mon, 29 Jun 2026 22:37:25 +0000 (22:37 +0000)
committerChristian Brabandt <cb@256bit.org>
Mon, 29 Jun 2026 22:37:25 +0000 (22:37 +0000)
Problem:  search_for_exact_line() repeatedly calls ins_compl_len() and
          relies on ternary operator precedence.
Solution: Cache the completion length and parenthesize the ternary
          expression.

closes: #20678

Signed-off-by: glepnir <glephunter@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
src/search.c
src/version.c

index 7db964f22bf622a3fcdb0c347ef98d236e48f5c4..bcf168be02e64045c9b1bda3bab949b15d04be66 100644 (file)
@@ -1788,6 +1788,7 @@ search_for_exact_line(
     linenr_T   start = 0;
     char_u     *ptr;
     char_u     *p;
+    int                compl_len = ins_compl_len();
 
     if (buf->b_ml.ml_line_count == 0)
        return FAIL;
@@ -1839,8 +1840,8 @@ search_for_exact_line(
        }
        else if (*p != NUL)     // ignore empty lines
        {       // expanding lines or words
-           if ((p_ic ? MB_STRNICMP(p, pat, ins_compl_len())
-                                  : STRNCMP(p, pat, ins_compl_len())) == 0)
+           if ((p_ic ? MB_STRNICMP(p, pat, compl_len)
+                                  : STRNCMP(p, pat, compl_len)) == 0)
                return OK;
        }
     }
@@ -3005,8 +3006,8 @@ is_zero_width(
            if (nmatched != 0)
                break;
        } while (regmatch.regprog != NULL
-               && direction == FORWARD ? regmatch.startpos[0].col < pos.col
-                                     : regmatch.startpos[0].col > pos.col);
+               && (direction == FORWARD ? regmatch.startpos[0].col < pos.col
+                                     : regmatch.startpos[0].col > pos.col));
 
        if (called_emsg == called_emsg_before)
        {
index 2bc636bde2a79ab487816f8d46d8caff90ec54e0..90ad6a7b5f9c46d8e2bf3d3c5ee2b1ad6cac3073 100644 (file)
@@ -759,6 +759,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    754,
 /**/
     753,
 /**/