diff options
author | zeertzjq <zeertzjq@outlook.com> | 2022-12-27 18:49:24 +0800 |
---|---|---|
committer | zeertzjq <zeertzjq@outlook.com> | 2022-12-27 18:54:47 +0800 |
commit | 59012a18e190532f673e72899b3e005e9792d8f8 (patch) | |
tree | 8d73a0aa0eaf948e1135eff16da5fd59ff621a1f | |
parent | 146c428a533b649adbc95fc29b41af42624b6ece (diff) | |
download | rneovim-59012a18e190532f673e72899b3e005e9792d8f8.tar.gz rneovim-59012a18e190532f673e72899b3e005e9792d8f8.tar.bz2 rneovim-59012a18e190532f673e72899b3e005e9792d8f8.zip |
vim-patch:9.0.1096: reallocating hashtab when the size didn't change
Problem: Reallocating hashtab when the size didn't change.
Solution: Bail out when the hashtab is already the desired size.
https://github.com/vim/vim/commit/71d53e7c579b8af44083142ea3894b455947ad81
Co-authored-by: Bram Moolenaar <Bram@vim.org>
-rw-r--r-- | src/nvim/hashtab.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/nvim/hashtab.c b/src/nvim/hashtab.c index fdbfdd7d77..448e78ab07 100644 --- a/src/nvim/hashtab.c +++ b/src/nvim/hashtab.c @@ -334,6 +334,11 @@ static void hash_may_resize(hashtab_T *ht, size_t minitems) assert(newsize != 0); } + // bail out if the hashtab is already at the desired size + if (newsize == ht->ht_mask + 1) { + return; + } + bool newarray_is_small = newsize == HT_INIT_SIZE; bool keep_smallarray = newarray_is_small && ht->ht_array == ht->ht_smallarray; |