From c39d2f7a76807cfa8198eb931ff6c58e6bb7fc67 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Wed, 18 Aug 2021 21:20:54 -0600 Subject: [PATCH] [bit-set-invertible] Implement add_array / add_sorted_array / intersects --- src/hb-bit-set-invertible.hh | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/hb-bit-set-invertible.hh b/src/hb-bit-set-invertible.hh index a3212b4e2..8ed5a1dc5 100644 --- a/src/hb-bit-set-invertible.hh +++ b/src/hb-bit-set-invertible.hh @@ -57,7 +57,7 @@ struct hb_bit_set_invertible_t template void add_array (const T *array, unsigned int count, unsigned int stride=sizeof(T)) - { /*XXX(inverted)*/s.add_array (array, count, stride); } + { inverted ? s.del_array (array, count, stride) : s.add_array (array, count, stride); } template void add_array (const hb_array_t& arr) { add_array (&arr, arr.len ()); } @@ -65,7 +65,7 @@ struct hb_bit_set_invertible_t * Used for faster rejection of corrupt data. */ template bool add_sorted_array (const T *array, unsigned int count, unsigned int stride=sizeof(T)) - { return /*XXX(inverted)*/s.add_sorted_array (array, count, stride); } + { return inverted ? s.del_sorted_array (array, count, stride) : s.add_sorted_array (array, count, stride); } template bool add_sorted_array (const hb_sorted_array_t& arr) { return add_sorted_array (&arr, arr.len ()); } @@ -89,7 +89,10 @@ struct hb_bit_set_invertible_t { add_range (range.first, range.second); return *this; } bool intersects (hb_codepoint_t first, hb_codepoint_t last) const - { return /*XXX(inverted)*/s.intersects (first, last); } + { + hb_codepoint_t c = first - 1; + return next (&c) && c <= last; + } void set (const hb_bit_set_invertible_t &other) { s.set (other.s); inverted = other.inverted; }