[bit-set-invertible] Second try fixing previous()

This commit is contained in:
Behdad Esfahbod 2021-08-19 16:33:48 -06:00
parent 8f88747a5e
commit 84c2a30214
1 changed files with 15 additions and 14 deletions

View File

@ -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);