[map] Destruct objects when clearing

This commit is contained in:
Behdad Esfahbod 2022-11-17 15:57:06 -07:00
parent 4caad5720c
commit 99103bd976
1 changed files with 7 additions and 1 deletions

View File

@ -96,6 +96,12 @@ struct hb_hashmap_t
is_used_ = false;
is_tombstone_ = false;
}
void reconstruct ()
{
key.~K ();
value.~V ();
construct ();
}
bool operator == (const K &o) { return hb_deref (key) == hb_deref (o); }
bool operator == (const item_t &o) { return *this == o.key; }
@ -237,7 +243,7 @@ struct hb_hashmap_t
if (unlikely (!successful)) return;
for (auto &_ : hb_iter (items, mask ? mask + 1 : 0))
_.construct ();
_.reconstruct ();
population = occupancy = 0;
}