From f2aaeeb3016e10bf91c251296391a381d5fc6385 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Fri, 14 Jul 2023 11:17:37 -0600 Subject: [PATCH] [subset/closure] Batch recursions in scheduled stages Going to revert. Doesn't pass tests and savings are minor. --- src/hb-ot-layout-gsub-table.hh | 9 +++++++-- src/hb-ot-layout-gsubgpos.hh | 15 +++++++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/hb-ot-layout-gsub-table.hh b/src/hb-ot-layout-gsub-table.hh index fd8a68be0..abde1c153 100644 --- a/src/hb-ot-layout-gsub-table.hh +++ b/src/hb-ot-layout-gsub-table.hh @@ -53,9 +53,14 @@ template /*static*/ typename hb_closure_context_t::return_t SubstLookup::closure_glyphs_recurse_func (hb_closure_context_t *c, unsigned lookup_index, hb_set_t *covered_seq_indices, unsigned seq_index, unsigned end_index) { const SubstLookup &l = c->face->table.GSUB.get_relaxed ()->table->get_lookup (lookup_index); - if (l.may_have_non_1to1 ()) + if (covered_seq_indices && l.may_have_non_1to1 ()) hb_set_add_range (covered_seq_indices, seq_index, end_index); - return l.dispatch (c); + + if (covered_seq_indices) + c->schedule (lookup_index); + else + l.dispatch (c); + return hb_empty_t (); } template <> diff --git a/src/hb-ot-layout-gsubgpos.hh b/src/hb-ot-layout-gsubgpos.hh index e10adb78b..a9c7017d8 100644 --- a/src/hb-ot-layout-gsubgpos.hh +++ b/src/hb-ot-layout-gsubgpos.hh @@ -183,8 +183,22 @@ struct hb_closure_context_t : void set_recurse_func (recurse_func_t func) { recurse_func = func; } + void schedule (unsigned lookup_index) + { + scheduled.add (lookup_index); + } + void flush () { + hb_set_t scheduled_copy; + while (scheduled) + { + scheduled_copy = scheduled; + scheduled.clear (); + for (unsigned lookup_index : scheduled_copy) + recurse (lookup_index, nullptr, 0, 0); + } + output->del_range (face->get_num_glyphs (), HB_SET_VALUE_INVALID); /* Remove invalid glyphs. */ glyphs->union_ (*output); output->clear (); @@ -196,6 +210,7 @@ struct hb_closure_context_t : hb_map_t *done_lookups_glyph_count; hb_hashmap_t> *done_lookups_glyph_set; unsigned int lookup_count = 0; + hb_set_t scheduled; };