[set] One more try at fixing clear() on empty set

This commit is contained in:
Behdad Esfahbod committed 2021-08-24 10:59:31 -06:00
1 parent fb07f8f876
commit 357976963e
1 file changed
+6 -9
+6 -9
View File
@@ -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 ();