[SingleSubstFormat2] Speed up closure

This commit is contained in:
Behdad Esfahbod 2022-11-30 11:37:49 -07:00
parent 2dc2e016d4
commit 72fabef0a4
1 changed files with 18 additions and 2 deletions

View File

@ -36,8 +36,24 @@ struct SingleSubstFormat2_4
void closure (hb_closure_context_t *c) const
{
+ hb_zip (this+coverage, substitute)
| hb_filter (c->parent_active_glyphs (), hb_first)
auto &cov = this+coverage;
auto &glyph_set = c->parent_active_glyphs ();
if (substitute.len > glyph_set.get_population () * 4)
{
for (auto g : glyph_set)
{
unsigned i = cov.get_coverage (g);
if (i == NOT_COVERED || i >= substitute.len)
continue;
c->output->add (substitute.arrayZ[i]);
}
return;
}
+ hb_zip (cov, substitute)
| hb_filter (glyph_set, hb_first)
| hb_map (hb_second)
| hb_sink (c->output)
;