From 1f578b5a32337011766e078331c0ba8ce4ce8af8 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Wed, 18 May 2022 15:24:40 -0600 Subject: [PATCH] [set] Add pre-allocation internal API --- src/hb-bit-set-invertible.hh | 1 + src/hb-bit-set.hh | 7 +++++++ src/hb-set.hh | 1 + 3 files changed, 9 insertions(+) diff --git a/src/hb-bit-set-invertible.hh b/src/hb-bit-set-invertible.hh index 2ec1c8fbe..18b80b5bb 100644 --- a/src/hb-bit-set-invertible.hh +++ b/src/hb-bit-set-invertible.hh @@ -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 (); diff --git a/src/hb-bit-set.hh b/src/hb-bit-set.hh index f20014576..e98e7377a 100644 --- a/src/hb-bit-set.hh +++ b/src/hb-bit-set.hh @@ -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; diff --git a/src/hb-set.hh b/src/hb-set.hh index 9eacaf4f6..18274b2f2 100644 --- a/src/hb-set.hh +++ b/src/hb-set.hh @@ -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 (); }