mirror of
https://github.com/vim/vim.git
synced 2025-07-26 11:04:33 -04:00
patch 9.0.1100: a hashtab with many removed items is not cleaned up
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.
This commit is contained in:
parent
81b7ecc5cb
commit
d0883faac6
@ -350,7 +350,7 @@ hash_may_resize(
|
|||||||
hashitem_T *olditem, *newitem;
|
hashitem_T *olditem, *newitem;
|
||||||
unsigned newi;
|
unsigned newi;
|
||||||
int todo;
|
int todo;
|
||||||
long_u oldsize, newsize;
|
long_u newsize;
|
||||||
long_u minsize;
|
long_u minsize;
|
||||||
long_u newmask;
|
long_u newmask;
|
||||||
hash_T perturb;
|
hash_T perturb;
|
||||||
@ -366,6 +366,7 @@ hash_may_resize(
|
|||||||
emsg("hash_may_resize(): table completely filled");
|
emsg("hash_may_resize(): table completely filled");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
long_u oldsize = ht->ht_mask + 1;
|
||||||
if (minitems == 0)
|
if (minitems == 0)
|
||||||
{
|
{
|
||||||
// Return quickly for small tables with at least two NULL items. NULL
|
// Return quickly for small tables with at least two NULL items. NULL
|
||||||
@ -380,7 +381,6 @@ hash_may_resize(
|
|||||||
* Shrink the array when it's less than 1/5 full. When growing it is
|
* 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)
|
* 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)
|
if (ht->ht_filled * 3 < oldsize * 2 && ht->ht_used > oldsize / 5)
|
||||||
return OK;
|
return OK;
|
||||||
|
|
||||||
@ -422,9 +422,10 @@ hash_may_resize(
|
|||||||
CLEAR_FIELD(ht->ht_smallarray);
|
CLEAR_FIELD(ht->ht_smallarray);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (newsize == ht->ht_mask + 1)
|
else if (newsize == oldsize && ht->ht_filled * 3 < oldsize * 2)
|
||||||
{
|
{
|
||||||
// the hashtab is already at the desired size, bail out
|
// The hashtab is already at the desired size, and there are not too
|
||||||
|
// many removed items, bail out.
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -695,6 +695,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
1100,
|
||||||
/**/
|
/**/
|
||||||
1099,
|
1099,
|
||||||
/**/
|
/**/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user