From 99ed6e29d86bbf391c12ee1f980b8af9dc35615e Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Fri, 10 May 2019 16:07:51 -0700 Subject: [PATCH] [serialize] Fix a TODO --- src/hb-ot-layout-common.hh | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/hb-ot-layout-common.hh b/src/hb-ot-layout-common.hh index 478e66c..2fd97cf 100644 --- a/src/hb-ot-layout-common.hh +++ b/src/hb-ot-layout-common.hh @@ -1043,12 +1043,16 @@ struct Coverage TRACE_SERIALIZE (this); if (unlikely (!c->extend_min (*this))) return_trace (false); - /* TODO(iter) Port to non-random-access iterator interface. */ - unsigned int count = glyphs.len (); - unsigned int num_ranges = 1; - for (unsigned int i = 1; i < count; i++) - if (glyphs[i - 1] + 1 != glyphs[i]) - num_ranges++; + unsigned count = 0; + unsigned num_ranges = 0; + hb_codepoint_t last = (hb_codepoint_t) -2; + for (auto g: glyphs) + { + if (last + 1 != g) + num_ranges++; + last = g; + count++; + } u.format = count * 2 < num_ranges * 3 ? 1 : 2; switch (u.format) -- 2.7.4