[set] Fix range-based-loop condition

Alternative to https://github.com/harfbuzz/harfbuzz/pull/2046
This commit is contained in:
Behdad Esfahbod 2019-11-18 13:09:29 -05:00
parent 4dae7cee4b
commit 78d5eca813
1 changed files with 10 additions and 3 deletions

View File

@ -698,8 +698,15 @@ struct hb_set_t
struct iter_t : hb_iter_with_fallback_t<iter_t, hb_codepoint_t> struct iter_t : hb_iter_with_fallback_t<iter_t, hb_codepoint_t>
{ {
static constexpr bool is_sorted_iterator = true; static constexpr bool is_sorted_iterator = true;
iter_t (const hb_set_t &s_ = Null(hb_set_t)) : iter_t (const hb_set_t &s_ = Null(hb_set_t),
s (&s_), v (INVALID), l (s->get_population () + 1) { __next__ (); } bool init = true) : s (&s_), v (INVALID), l(0)
{
if (init)
{
l = s->get_population () + 1;
__next__ ();
}
}
typedef hb_codepoint_t __item_t__; typedef hb_codepoint_t __item_t__;
hb_codepoint_t __item__ () const { return v; } hb_codepoint_t __item__ () const { return v; }
@ -707,7 +714,7 @@ struct hb_set_t
void __next__ () { s->next (&v); if (l) l--; } void __next__ () { s->next (&v); if (l) l--; }
void __prev__ () { s->previous (&v); } void __prev__ () { s->previous (&v); }
unsigned __len__ () const { return l; } unsigned __len__ () const { return l; }
iter_t end () const { return iter_t (*s); } iter_t end () const { return iter_t (*s, false); }
bool operator != (const iter_t& o) const bool operator != (const iter_t& o) const
{ return s != o.s || v != o.v; } { return s != o.s || v != o.v; }