diff --git a/src/hb-bit-set-invertible.hh b/src/hb-bit-set-invertible.hh index 5be6e451d..ab48239bb 100644 --- a/src/hb-bit-set-invertible.hh +++ b/src/hb-bit-set-invertible.hh @@ -211,6 +211,12 @@ struct hb_bit_set_invertible_t return s.next (codepoint); auto old = *codepoint; + if (unlikely (old + 1 == INVALID)) + { + *codepoint = INVALID; + return false; + } + auto v = old; s.next (&v); if (old + 1 < v) @@ -219,12 +225,6 @@ struct hb_bit_set_invertible_t return true; } - if (unlikely (old + 1 == INVALID)) - { - *codepoint = INVALID; - return false; - } - v = old; s.next_range (&old, &v); @@ -237,20 +237,21 @@ struct hb_bit_set_invertible_t return s.previous (codepoint); auto old = *codepoint; - auto v = old; - s.previous (&v); - if (old - 1 > v || v == INVALID) - { - *codepoint = old - 1; - return true; - } - if (unlikely (old - 1 == INVALID)) { *codepoint = INVALID; return false; } + auto v = old; + s.previous (&v); + + if (old - 1 > v || v == INVALID) + { + *codepoint = old - 1; + return true; + } + v = old; s.previous_range (&v, &old);