[CoverageFormat2] Optimize intersects()

This commit is contained in:
Behdad Esfahbod 2022-12-03 13:17:15 -07:00
parent c482b06108
commit 1f4d8ccaed
1 changed files with 8 additions and 0 deletions

View File

@ -115,6 +115,14 @@ struct CoverageFormat2_4
bool intersects (const hb_set_t *glyphs) const
{
if (rangeRecord.len > glyphs->get_population () * hb_bit_storage ((unsigned) rangeRecord.len) / 2)
{
for (hb_codepoint_t g = HB_SET_VALUE_INVALID; glyphs->next (&g);)
if (get_coverage (g) != NOT_COVERED)
return true;
return false;
}
return hb_any (+ hb_iter (rangeRecord)
| hb_map ([glyphs] (const RangeRecord<Types> &range) { return range.intersects (*glyphs); }));
}