From c88e7ec935caf31ca7db6b90ab0db514c1b65e45 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Sun, 15 Aug 2021 11:39:31 -0600 Subject: [PATCH] [set] Add page_t::elt_maybe_invert() --- src/hb-set.hh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/hb-set.hh b/src/hb-set.hh index 789cbcfa3..7f1429ddc 100644 --- a/src/hb-set.hh +++ b/src/hb-set.hh @@ -190,7 +190,7 @@ struct hb_set_t { for (unsigned int i = 0; i < len (); i++) { - elt_t e = inverted ? ~v[i] : v[i]; + elt_t e = elt_maybe_invert (v[i], inverted); if (e) return i * ELT_BITS + elt_get_min (e); } @@ -200,7 +200,7 @@ struct hb_set_t { for (int i = len () - 1; i >= 0; i--) { - elt_t e = inverted ? ~v[i] : v[i]; + elt_t e = elt_maybe_invert (v[i], inverted); if (e) return i * ELT_BITS + elt_get_max (e); } @@ -213,6 +213,7 @@ struct hb_set_t static unsigned int elt_get_min (const elt_t &elt) { return hb_ctz (elt); } static unsigned int elt_get_max (const elt_t &elt) { return hb_bit_storage (elt) - 1; } + static elt_t elt_maybe_invert (elt_t elt, bool inverted) { return inverted ? ~elt : elt; } typedef hb_vector_size_t vector_t;