vim-patch:8.1.1752: resizing hashtable is inefficient (#35563)

Problem:    Resizing hashtable is inefficient.
Solution:   Avoid resizing when the final size is predictable.

7b73d7ebf7

Co-authored-by: Bram Moolenaar <Bram@vim.org>
This commit is contained in:
Jan Edmund Lazo
2025-08-31 01:29:43 -04:00
committed by GitHub
parent 6a330f893b
commit 582e0714b5

View File

@@ -317,7 +317,7 @@ static void hash_may_resize(hashtab_T *ht, size_t minitems)
// Use specified size.
minitems = MAX(minitems, ht->ht_used);
// array is up to 2/3 full
minsize = minitems * 3 / 2;
minsize = (minitems * 3 + 1) / 2;
}
size_t newsize = HT_INIT_SIZE;