[set] Add pre-allocation internal API

This commit is contained in:
Behdad Esfahbod 2022-05-18 15:24:40 -06:00
parent 48dfbd54a3
commit 1f578b5a32
3 changed files with 9 additions and 0 deletions

View File

@ -56,6 +56,7 @@ struct hb_bit_set_invertible_t
bool in_error () const { return s.in_error (); }
explicit operator bool () const { return !is_empty (); }
void alloc (unsigned sz) { s.alloc (sz); }
void reset ()
{
s.reset ();

View File

@ -97,6 +97,13 @@ struct hb_bit_set_t
return true;
}
void alloc (unsigned sz)
{
sz >>= (page_t::PAGE_BITS_LOG_2 - 1);
pages.alloc (sz);
page_map.alloc (sz);
}
void reset ()
{
successful = true;

View File

@ -77,6 +77,7 @@ struct hb_sparseset_t
void err () { s.err (); }
bool in_error () const { return s.in_error (); }
void alloc (unsigned sz) { s.alloc (sz); }
void reset () { s.reset (); }
void clear () { s.clear (); }
void invert () { s.invert (); }