]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.1.1181: Unnecessary STRLEN() calls in insexpand.c v9.1.1181
authorzeertzjq <zeertzjq@outlook.com>
Fri, 7 Mar 2025 18:06:02 +0000 (19:06 +0100)
committerChristian Brabandt <cb@256bit.org>
Fri, 7 Mar 2025 18:06:02 +0000 (19:06 +0100)
Problem:  Unnecessary STRLEN() calls in insexpand.c (after 9.1.1178).
Solution: Use the already available length (zeertzjq).

closes: #16814

Signed-off-by: zeertzjq <zeertzjq@outlook.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
src/insexpand.c
src/version.c

index 9769c46c25ad77ae42faca6e9809a79c1c763189..f7700413102e486fc9bd0ddbaf3f600d891b29dc 100644 (file)
@@ -3934,7 +3934,7 @@ fuzzy_longest_match(void)
     }
 
     prefix = compl_best_matches[0]->cp_str.string;
-    prefix_len = (int)STRLEN(prefix);
+    prefix_len = (int)compl_best_matches[0]->cp_str.length;
 
     for (i = 1; i < compl_num_bests; i++)
     {
@@ -3958,14 +3958,13 @@ fuzzy_longest_match(void)
     }
 
     leader = ins_compl_leader();
-    if (leader != NULL)
-       leader_len = STRLEN(leader);
+    leader_len = ins_compl_leader_len();
 
     // skip non-consecutive prefixes
-    if (STRNCMP(prefix, leader, leader_len) != 0)
+    if (leader_len > 0 && STRNCMP(prefix, leader, leader_len) != 0)
        goto end;
 
-    prefix = vim_strnsave(compl_best_matches[0]->cp_str.string, prefix_len);
+    prefix = vim_strnsave(prefix, prefix_len);
     if (prefix != NULL)
     {
        ins_compl_longest_insert(prefix);
@@ -5829,8 +5828,10 @@ ins_compl_start(void)
     compl_orig_text.string = vim_strnsave(line + compl_col, (size_t)compl_length);
     if (p_ic)
        flags |= CP_ICASE;
-    if (compl_orig_text.string == NULL || ins_compl_add(compl_orig_text.string,
-               -1, NULL, NULL, NULL, 0, flags, FALSE, NULL, 0) != OK)
+    if (compl_orig_text.string == NULL
+           || ins_compl_add(compl_orig_text.string,
+               (int)compl_orig_text.length,
+               NULL, NULL, NULL, 0, flags, FALSE, NULL, 0) != OK)
     {
        VIM_CLEAR_STRING(compl_pattern);
        VIM_CLEAR_STRING(compl_orig_text);
index 0592d80839d4e4ed913a4af2d467159b3174fd54..ad0cbcc73f3f2aed42d576f9348bed34d792c91c 100644 (file)
@@ -704,6 +704,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1181,
 /**/
     1180,
 /**/