From 78d5eca813250b79e9b1fbfd2de3eae7ccf1fcf3 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Mon, 18 Nov 2019 13:09:29 -0500 Subject: [PATCH] [set] Fix range-based-loop condition Alternative to https://github.com/harfbuzz/harfbuzz/pull/2046 --- src/hb-set.hh | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) 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; }