Add a set-digest for second glyph in PairPosFormat1 Doesn't show any speedup.
diff --git a/src/OT/Layout/GPOS/PairPosFormat1.hh b/src/OT/Layout/GPOS/PairPosFormat1.hh index a8ded1e..8d06b3b 100644 --- a/src/OT/Layout/GPOS/PairPosFormat1.hh +++ b/src/OT/Layout/GPOS/PairPosFormat1.hh
@@ -106,6 +106,7 @@ struct external_cache_t { hb_ot_layout_mapping_cache_t coverage; + hb_set_digest_t seconds; }; void *external_cache_create () const { @@ -113,6 +114,12 @@ if (likely (cache)) { cache->coverage.clear (); + + cache->seconds.init (); + + hb_iter (pairSet) + | hb_map (hb_add (this)) + | hb_apply ([cache, this] (const PairSet &_) { _.collect_seconds (cache->seconds, this->valueFormat); }) + ; } return cache; } @@ -125,8 +132,10 @@ #ifndef HB_NO_OT_LAYOUT_LOOKUP_CACHE external_cache_t *cache = (external_cache_t *) external_cache; + const hb_set_digest_t *seconds = cache ? &cache->seconds : nullptr; unsigned int index = (this+coverage).get_coverage (buffer->cur().codepoint, cache ? &cache->coverage : nullptr); #else + const hb_set_digest_t *seconds = nullptr; unsigned int index = (this+coverage).get_coverage (buffer->cur().codepoint); #endif if (index == NOT_COVERED) return_trace (false); @@ -140,6 +149,12 @@ return_trace (false); } + if (seconds && !seconds->may_have (buffer->info[skippy_iter.idx].codepoint)) + { + buffer->unsafe_to_concat (buffer->idx, skippy_iter.idx + 1); + return_trace (false); + } + return_trace ((this+pairSet[index]).apply (c, valueFormat, skippy_iter.idx)); }
diff --git a/src/OT/Layout/GPOS/PairSet.hh b/src/OT/Layout/GPOS/PairSet.hh index 5560fab..ca54657 100644 --- a/src/OT/Layout/GPOS/PairSet.hh +++ b/src/OT/Layout/GPOS/PairSet.hh
@@ -84,6 +84,21 @@ c->input->add_array (&record->secondGlyph, len, record_size); } + template <typename set_t> + void collect_seconds (set_t &s, + const ValueFormat *valueFormats) const + { + unsigned record_size = get_size (valueFormats); + + const PairValueRecord *record = &firstPairValueRecord; + unsigned count = len; + for (unsigned i = 0; i < count; i++) + { + s.add (record->secondGlyph); + record = &StructAtOffset<const PairValueRecord> (record, record_size); + } + } + void collect_variation_indices (hb_collect_variation_indices_context_t *c, const ValueFormat *valueFormats) const {