From 357976963ec7228d4790d9524142943f5ecf112e Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Tue, 24 Aug 2021 10:55:12 -0600 Subject: [PATCH] [set] One more try at fixing clear() on empty set --- src/hb-bit-set.hh | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/hb-bit-set.hh b/src/hb-bit-set.hh index ff536abd6..2267266e1 100644 --- a/src/hb-bit-set.hh +++ b/src/hb-bit-set.hh @@ -78,7 +78,8 @@ struct hb_bit_set_t bool resize (unsigned int count) { - if (unlikely (count > pages.length && !successful)) return false; + if (unlikely (!successful)) return false; + if (count <= pages.length) return true; if (unlikely (!pages.resize (count) || !page_map.resize (count))) { pages.resize (page_map.length); @@ -328,7 +329,7 @@ struct hb_bit_set_t { if (unlikely (!successful)) return; unsigned int count = other.pages.length; - if (!resize (count)) + if (unlikely (!resize (count))) return; population = other.population; @@ -508,7 +509,7 @@ struct hb_bit_set_t compact (compact_workspace, write_index); } - if (!resize (count)) + if (unlikely (!resize (count))) return; newCount = count; @@ -564,11 +565,7 @@ struct hb_bit_set_t page_at (count).v = other.page_at (b).v; } assert (!count); - if (pages.length > newCount) - // This resize() doesn't need to be checked because we can't get here - // if the set is currently in_error() and this only resizes downwards - // which will always succeed if the set is not in_error(). - resize (newCount); + resize (newCount); } void union_ (const hb_bit_set_t &other) { process (hb_bitwise_or, other); } @@ -782,7 +779,7 @@ struct hb_bit_set_t if (!insert) return nullptr; - if (!resize (pages.length + 1)) + if (unlikely (!resize (pages.length + 1))) return nullptr; pages[map.index].init0 ();