From 7525e87f107f1be13bf0aced78cb904b02cc186e Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 13 Aug 2026 07:46:22 +0800 Subject: [PATCH] vim-patch:9.2.0953: insert completion code can be improved Problem: The duplicate-check hashtab in insexpand.c has comments that do not add anything to what the code says (after v9.2.0909). Solution: Drop the redundant comments. related: vim/vim#20926 closes: vim/vim#21027 https://github.com/vim/vim/commit/4dde4afa1d188d92aa7ae91db43956bd83aad758 Co-authored-by: Hirohito Higashi Co-Authored-By: Claude Opus 5 (1M context) --- src/nvim/insexpand.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/nvim/insexpand.c b/src/nvim/insexpand.c index 9228599831..e324c54198 100644 --- a/src/nvim/insexpand.c +++ b/src/nvim/insexpand.c @@ -228,11 +228,9 @@ static compl_T *compl_old_match = NULL; static compl_T *compl_preselect_match = NULL; /// Hashtab with the strings of the matches in the list above, except the -/// original-text entries. Used to make the duplicate check O(1) instead of -/// a scan of the whole list. Each entry owns a copy of the string and -/// counts the matches with that string, so that when matches were added -/// with "adup" the entry remains until the last match with the string is -/// removed. +/// original-text entries. Each entry owns a copy of the string and counts +/// the matches with that string, so that when matches were added with "adup" +/// the entry remains until the last match with the string is removed. typedef struct { int cse_count; // number of matches with this string char cse_str[]; // the string @@ -244,8 +242,7 @@ typedef struct { static hashtab_T compl_strings_ht; /// Count the string of a new match in the duplicate-check hashtab. -/// "hash" is the hash of "str" when it is not zero, saving hashing the -/// string again. +/// "hash" is the hash of "str" when it is not zero. static void compl_strings_add(const char *str, size_t len, hash_T hash) { if (compl_strings_ht.ht_array == NULL) { @@ -1008,8 +1005,7 @@ static int ins_compl_add(char *const str, int len, char *const fname, char *cons // If the same match is already present, don't add it. if (compl_first_match != NULL && !adup && compl_strings_ht.ht_used > 0) { - // Use a stack buffer for the NUL-terminated key when it fits, so - // that rejecting a duplicate does not allocate memory. + // The key must be NUL terminated. char keybuf[128]; char *key; if (len < (int)sizeof(keybuf)) {