[map] Don't resize map if not necessary

This commit is contained in:
Behdad Esfahbod 2022-11-17 15:25:45 -07:00
parent 7595fa2d9a
commit 896377463f
1 changed files with 2 additions and 0 deletions

View File

@ -160,6 +160,8 @@ struct hb_hashmap_t
{
if (unlikely (!successful)) return false;
if (new_population != 0 && new_population <= population) return true;
unsigned int power = hb_bit_storage (hb_max (population, new_population) * 2 + 8);
unsigned int new_size = 1u << power;
item_t *new_items = (item_t *) hb_malloc ((size_t) new_size * sizeof (item_t));