aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2025-03-08 05:55:28 +0800
committerzeertzjq <zeertzjq@outlook.com>2025-03-27 07:26:42 +0800
commit17db70f3af382211b82574d03b227164f4db510b (patch)
treee0b18597113043b39509f3312a828b3542c52a2e
parent90d59e6c8aa6141c54f81586df423e5a76e009f9 (diff)
downloadrneovim-17db70f3af382211b82574d03b227164f4db510b.tar.gz
rneovim-17db70f3af382211b82574d03b227164f4db510b.tar.bz2
rneovim-17db70f3af382211b82574d03b227164f4db510b.zip
vim-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: vim/vim#16814 https://github.com/vim/vim/commit/4422de6316b544c282e6c74afd3df3ee3a4b1cfd
-rw-r--r--src/nvim/insexpand.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/nvim/insexpand.c b/src/nvim/insexpand.c
index fc4c9c9807..0b85fc23e8 100644
--- a/src/nvim/insexpand.c
+++ b/src/nvim/insexpand.c
@@ -3427,7 +3427,7 @@ static void fuzzy_longest_match(void)
}
char *prefix = compl_best_matches[0]->cp_str.data;
- int prefix_len = (int)strlen(prefix);
+ int prefix_len = (int)compl_best_matches[0]->cp_str.size;
for (int i = 1; i < compl_num_bests; i++) {
char *match_str = compl_best_matches[i]->cp_str.data;
@@ -3451,14 +3451,14 @@ static void fuzzy_longest_match(void)
}
char *leader = ins_compl_leader();
- size_t leader_len = leader != NULL ? strlen(leader) : 0;
+ size_t 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 = xmemdupz(compl_best_matches[0]->cp_str.data, (size_t)prefix_len);
+ prefix = xmemdupz(prefix, (size_t)prefix_len);
ins_compl_longest_insert(prefix);
compl_cfc_longest_ins = true;
xfree(prefix);
@@ -5051,7 +5051,7 @@ static int ins_compl_start(void)
if (p_ic) {
flags |= CP_ICASE;
}
- if (ins_compl_add(compl_orig_text.data, -1,
+ if (ins_compl_add(compl_orig_text.data, (int)compl_orig_text.size,
NULL, NULL, false, NULL, 0,
flags, false, NULL, 0) != OK) {
API_CLEAR_STRING(compl_pattern);