[bit-set-invertible] Rewrite next/previous() using s.next/previous_range()
This commit is contained in:
parent
248ad3bce5
commit
eb98bc1e32
|
@ -181,21 +181,24 @@ struct hb_bit_set_invertible_t
|
||||||
return s.next (codepoint);
|
return s.next (codepoint);
|
||||||
|
|
||||||
auto old = *codepoint;
|
auto old = *codepoint;
|
||||||
do
|
auto v = old;
|
||||||
|
s.next (&v);
|
||||||
|
if (old + 1 < v)
|
||||||
{
|
{
|
||||||
auto v = old;
|
*codepoint = old + 1;
|
||||||
s.next (&v);
|
return true;
|
||||||
if (old + 1 < v)
|
|
||||||
{
|
|
||||||
*codepoint = old + 1;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
old++;
|
|
||||||
}
|
}
|
||||||
while (old != INVALID);
|
|
||||||
|
|
||||||
*codepoint = INVALID;
|
if (unlikely (old + 1 == INVALID))
|
||||||
return false;
|
{
|
||||||
|
*codepoint = INVALID;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
s.next_range (&old, &v);
|
||||||
|
|
||||||
|
*codepoint = v + 1;
|
||||||
|
return *codepoint != INVALID;
|
||||||
}
|
}
|
||||||
bool previous (hb_codepoint_t *codepoint) const
|
bool previous (hb_codepoint_t *codepoint) const
|
||||||
{
|
{
|
||||||
|
@ -203,21 +206,24 @@ struct hb_bit_set_invertible_t
|
||||||
return s.previous (codepoint);
|
return s.previous (codepoint);
|
||||||
|
|
||||||
auto old = *codepoint;
|
auto old = *codepoint;
|
||||||
do
|
auto v = old;
|
||||||
|
s.previous (&v);
|
||||||
|
if (old - 1 > v)
|
||||||
{
|
{
|
||||||
auto v = old;
|
*codepoint = old - 1;
|
||||||
s.previous (&v);
|
return true;
|
||||||
if (old - 1 > v)
|
|
||||||
{
|
|
||||||
*codepoint = old - 1;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
old--;
|
|
||||||
}
|
}
|
||||||
while (old != INVALID);
|
|
||||||
|
|
||||||
*codepoint = INVALID;
|
if (unlikely (old - 1 == INVALID))
|
||||||
return false;
|
{
|
||||||
|
*codepoint = INVALID;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
s.previous_range (&v, &old);
|
||||||
|
|
||||||
|
*codepoint = v - 1;
|
||||||
|
return *codepoint != INVALID;
|
||||||
}
|
}
|
||||||
bool next_range (hb_codepoint_t *first, hb_codepoint_t *last) const
|
bool next_range (hb_codepoint_t *first, hb_codepoint_t *last) const
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue