neovim

Neovim text editor
git clone https://git.dasho.dev/neovim.git
Log | Files | Refs | README

commit 17db70f3af382211b82574d03b227164f4db510b
parent 90d59e6c8aa6141c54f81586df423e5a76e009f9
Author: zeertzjq <zeertzjq@outlook.com>
Date:   Sat,  8 Mar 2025 05:55:28 +0800

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

Diffstat:
Msrc/nvim/insexpand.c | 10+++++-----
1 file changed, 5 insertions(+), 5 deletions(-)

diff --git 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);