[set] Allocate first page exact

This commit is contained in:
Behdad Esfahbod 2023-01-05 14:08:47 -07:00
parent 0b7f6d6cf0
commit 207ae11ab9
1 changed files with 4 additions and 0 deletions

View File

@ -88,6 +88,10 @@ struct hb_bit_set_t
bool resize (unsigned int count, bool clear = true, bool exact_size = false)
{
if (unlikely (!successful)) return false;
if (pages.length == 0 && count == 1)
exact_size = true; // Most sets are small and local
if (unlikely (!pages.resize (count, clear, exact_size) || !page_map.resize (count, clear, exact_size)))
{
pages.resize (page_map.length, clear, exact_size);