From 048e3b596fb7fccd3fb5f48de98b6b67788f774a Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Sat, 4 Aug 2012 18:04:57 -0700 Subject: [PATCH] Speed up hb_set_digest_lowest_bits_t calcs --- src/hb-set-private.hh | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/hb-set-private.hh b/src/hb-set-private.hh index 8beff37d4..441357929 100644 --- a/src/hb-set-private.hh +++ b/src/hb-set-private.hh @@ -83,9 +83,13 @@ struct hb_set_digest_lowest_bits_t } inline void add_range (hb_codepoint_t a, hb_codepoint_t b) { - /* TODO Speedup. */ - for (unsigned int i = a; i < b + 1; i++) - add (i); + if (b - a >= sizeof (mask_t) * 8 - 1) + mask = (mask_t) -1; + else { + mask_t ma = mask_for (a); + mask_t mb = mask_for (b); + mask |= mb + (mb - ma) - (mb < ma); + } } inline bool may_have (hb_codepoint_t g) const {