[set] Save a few kilobytes via type erasure of process()

This commit is contained in:
Behdad Esfahbod 2022-07-13 13:22:34 -06:00
parent 42da7da5ef
commit e5f0bc8f0a
1 changed files with 12 additions and 5 deletions

View File

@ -465,12 +465,10 @@ struct hb_bit_set_t
}
public:
template <typename Op>
void process (const Op& op, const hb_bit_set_t &other)
void process_ (hb_bit_page_t::vector_t (*op) (const hb_bit_page_t::vector_t &, const hb_bit_page_t::vector_t &),
bool passthru_left, bool passthru_right,
const hb_bit_set_t &other)
{
const bool passthru_left = op (1, 0);
const bool passthru_right = op (0, 1);
if (unlikely (!successful)) return;
dirty ();
@ -590,6 +588,15 @@ struct hb_bit_set_t
assert (!count);
resize (newCount);
}
template <typename Op>
static hb_bit_page_t::vector_t
op_ (const hb_bit_page_t::vector_t &a, const hb_bit_page_t::vector_t &b)
{ return Op{} (a, b); }
template <typename Op>
void process (const Op& op, const hb_bit_set_t &other)
{
process_ (op_<Op>, op (1, 0), op (0, 1), other);
}
void union_ (const hb_bit_set_t &other) { process (hb_bitwise_or, other); }
void intersect (const hb_bit_set_t &other) { process (hb_bitwise_and, other); }