[CoverageFormat2] Remove hand-written loop

While on a fuzzer-found test case (added) that loop was faster,
on real fonts, including NotoNastaliq in our benchmark, it was
actually slower, which intuitively I would have expected.

Still no idea why on that fuzzer case it's faster though. :(
This commit is contained in:
Behdad Esfahbod 2022-07-21 12:35:19 -06:00
parent bbb4db90dd
commit 9eab3ac72d
2 changed files with 5 additions and 30 deletions

View File

@ -142,37 +142,12 @@ struct CoverageFormat2_4
hb_requires (hb_is_sink_of (IterableOut, hb_codepoint_t))>
void intersect_set (const hb_set_t &glyphs, IterableOut &intersect_glyphs) const
{
/* Why the second branch is >2x faster I have no idea, but it seems to be. */
if (0)
for (const auto& range : rangeRecord)
{
for (const auto& range : rangeRecord)
{
hb_codepoint_t last = range.last;
for (hb_codepoint_t g = range.first - 1;
glyphs.next (&g) && g <= last;)
intersect_glyphs << g;
}
}
else
{
iter_t c_iter;
c_iter.init (*this);
auto s_iter = hb_iter (glyphs);
while (c_iter.__more__ () && s_iter)
{
hb_codepoint_t cv = c_iter.get_glyph ();
hb_codepoint_t sv = *s_iter;
if (cv == sv)
{
intersect_glyphs << cv;
c_iter.__next__ ();
s_iter++;
}
else if (cv < sv)
c_iter.__next__ ();
else
s_iter++;
}
hb_codepoint_t last = range.last;
for (hb_codepoint_t g = range.first - 1;
glyphs.next (&g) && g <= last;)
intersect_glyphs << g;
}
}