diff --git a/src/hb-private.hh b/src/hb-private.hh index f2f580a54..fb07e2451 100644 --- a/src/hb-private.hh +++ b/src/hb-private.hh @@ -786,20 +786,16 @@ struct hb_auto_trace_t<0, ret_t> { /* Misc */ +template class hb_assert_unsigned_t; +template <> class hb_assert_unsigned_t {}; +template <> class hb_assert_unsigned_t {}; +template <> class hb_assert_unsigned_t {}; -/* Pre-mature optimization: - * Checks for lo <= u <= hi but with an optimization if lo and hi - * are only different in a contiguous set of lower-most bits. - */ template static inline bool hb_in_range (T u, T lo, T hi) { - if ( ((lo^hi) & lo) == 0 && - ((lo^hi) & hi) == (lo^hi) && - ((lo^hi) & ((lo^hi) + 1)) == 0 ) - return (u & ~(lo^hi)) == lo; - else - return lo <= u && u <= hi; + hb_assert_unsigned_t error_hb_in_range_called_with_signed_type HB_UNUSED; + return (u - lo) <= (hi - lo); } template static inline bool