From 99103bd9768fbb2063542c60ecdae317df0ce155 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Thu, 17 Nov 2022 15:57:06 -0700 Subject: [PATCH] [map] Destruct objects when clearing --- src/hb-map.hh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/hb-map.hh b/src/hb-map.hh index 93521b5f1..9c0aedaf9 100644 --- a/src/hb-map.hh +++ b/src/hb-map.hh @@ -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; }