patch 9.1.1181: Unnecessary STRLEN() calls in insexpand.c Commit: https://github.com/vim/vim/commit/4422de6316b544c282e6c74afd3df3ee3a4b1cfd Author: zeertzjq <zeert...@outlook.com> Date: Fri Mar 7 19:06:02 2025 +0100
patch 9.1.1181: Unnecessary STRLEN() calls in insexpand.c Problem: Unnecessary STRLEN() calls in insexpand.c (after 9.1.1178). Solution: Use the already available length (zeertzjq). closes: #16814 Signed-off-by: zeertzjq <zeert...@outlook.com> Signed-off-by: Christian Brabandt <c...@256bit.org> diff --git a/src/insexpand.c b/src/insexpand.c index 9769c46c2..f77004131 100644 --- a/src/insexpand.c +++ b/src/insexpand.c @@ -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); diff --git a/src/version.c b/src/version.c index 0592d8083..ad0cbcc73 100644 --- a/src/version.c +++ b/src/version.c @@ -704,6 +704,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 1181, /**/ 1180, /**/ -- -- You received this message from the "vim_dev" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscr...@googlegroups.com. To view this discussion visit https://groups.google.com/d/msgid/vim_dev/E1tqcDw-00EGT6-CU%40256bit.org.