To: vim_dev@googlegroups.com Subject: Patch 9.0.1100 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 9.0.1100 Problem: A hashtab with many removed items is not cleaned up. Solution: Re-hash a hashtab even when the size didn't change if too many items were removed. Files: src/hashtab.c *** ../vim-9.0.1099/src/hashtab.c 2022-12-26 13:08:01.597571746 +0000 --- src/hashtab.c 2022-12-26 13:44:05.430523664 +0000 *************** *** 350,356 **** hashitem_T *olditem, *newitem; unsigned newi; int todo; ! long_u oldsize, newsize; long_u minsize; long_u newmask; hash_T perturb; --- 350,356 ---- hashitem_T *olditem, *newitem; unsigned newi; int todo; ! long_u newsize; long_u minsize; long_u newmask; hash_T perturb; *************** *** 366,371 **** --- 366,372 ---- emsg("hash_may_resize(): table completely filled"); #endif + long_u oldsize = ht->ht_mask + 1; if (minitems == 0) { // Return quickly for small tables with at least two NULL items. NULL *************** *** 380,386 **** * Shrink the array when it's less than 1/5 full. When growing it is * at least 1/4 full (avoids repeated grow-shrink operations) */ - oldsize = ht->ht_mask + 1; if (ht->ht_filled * 3 < oldsize * 2 && ht->ht_used > oldsize / 5) return OK; --- 381,386 ---- *************** *** 422,430 **** CLEAR_FIELD(ht->ht_smallarray); } ! else if (newsize == ht->ht_mask + 1) { ! // the hashtab is already at the desired size, bail out return OK; } --- 422,431 ---- CLEAR_FIELD(ht->ht_smallarray); } ! else if (newsize == oldsize && ht->ht_filled * 3 < oldsize * 2) { ! // The hashtab is already at the desired size, and there are not too ! // many removed items, bail out. return OK; } *** ../vim-9.0.1099/src/version.c 2022-12-26 13:08:01.597571746 +0000 --- src/version.c 2022-12-26 13:46:07.098173450 +0000 *************** *** 697,698 **** --- 697,700 ---- { /* Add new patch number below this line */ + /**/ + 1100, /**/ -- TIM: But follow only if you are men of valour. For the entrance to this cave is guarded by a monster, a creature so foul and cruel that no man yet has fought with it and lived. Bones of full fifty men lie strewn about its lair ... "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// \\\ \\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///