diff --git a/src/hb-set.hh b/src/hb-set.hh index 36d11c031..7603526e7 100644 --- a/src/hb-set.hh +++ b/src/hb-set.hh @@ -698,8 +698,15 @@ struct hb_set_t struct iter_t : hb_iter_with_fallback_t { static constexpr bool is_sorted_iterator = true; - iter_t (const hb_set_t &s_ = Null(hb_set_t)) : - s (&s_), v (INVALID), l (s->get_population () + 1) { __next__ (); } + iter_t (const hb_set_t &s_ = Null(hb_set_t), + bool init = true) : s (&s_), v (INVALID), l(0) + { + if (init) + { + l = s->get_population () + 1; + __next__ (); + } + } typedef hb_codepoint_t __item_t__; hb_codepoint_t __item__ () const { return v; } @@ -707,7 +714,7 @@ struct hb_set_t void __next__ () { s->next (&v); if (l) l--; } void __prev__ () { s->previous (&v); } 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 { return s != o.s || v != o.v; }