[CoverageFormat1] Speed up intersects()

Speeds up SourceHanSerif/10000 benchmark (not in test suite) by
32%!
This commit is contained in:
Behdad Esfahbod 2022-12-03 09:57:29 -07:00
parent a2d33779e1
commit 4d19c724c0
1 changed files with 8 additions and 3 deletions

View File

@ -77,9 +77,14 @@ struct CoverageFormat1_3
bool intersects (const hb_set_t *glyphs) const bool intersects (const hb_set_t *glyphs) const
{ {
/* TODO Speed up, using hb_set_next() and bsearch()? if (glyphArray.len > glyphs->get_population () * hb_bit_storage ((unsigned) glyphArray.len) / 2)
* Experience with other tables suggest that it would {
* not speed up though. */ for (hb_codepoint_t g = HB_SET_VALUE_INVALID; glyphs->next (&g);)
if (get_coverage (g) != NOT_COVERED)
return true;
return false;
}
for (const auto& g : glyphArray.as_array ()) for (const auto& g : glyphArray.as_array ())
if (glyphs->has (g)) if (glyphs->has (g))
return true; return true;