From 12b0680e60ece83844436f61d4269ce38f689c8f Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Tue, 23 May 2023 10:49:41 -0600 Subject: [PATCH] [map] Fix set() This was broken in 2133aa2407657d0b3b4b73a4951c05ed26d055f2. We have to keep probing over tombstones. --- src/hb-map.hh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/hb-map.hh b/src/hb-map.hh index 21c7ba1b4..540204104 100644 --- a/src/hb-map.hh +++ b/src/hb-map.hh @@ -207,6 +207,7 @@ struct hb_hashmap_t if (unlikely ((occupancy + occupancy / 2) >= mask && !resize ())) return false; hash &= 0x3FFFFFFF; // We only store lower 30bit of hash + unsigned int tombstone = (unsigned int) -1; unsigned int i = hash % prime; unsigned step = 0; while (items[i].is_used ()) @@ -214,12 +215,12 @@ struct hb_hashmap_t if ((hb_is_same (K, hb_codepoint_t) || items[i].hash == hash) && items[i] == key) break; - if (items[i].is_tombstone ()) - break; + if (tombstone == (unsigned) -1 && items[i].is_tombstone ()) + tombstone = i; i = (i + ++step) & mask; } - item_t &item = items[i]; + item_t &item = items[tombstone == (unsigned) -1 ? i : tombstone]; if (item.is_used ()) {