From f629ecdc5c143c7fd769b516e25758a008d73fc4 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Sat, 20 Dec 2025 16:29:07 -0700 Subject: [PATCH] [contextual] Implement rule-skipping for ChainContext as well Speeds up NotoNastaliq benchmark another 5%. --- src/hb-ot-layout-gsubgpos.hh | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/hb-ot-layout-gsubgpos.hh b/src/hb-ot-layout-gsubgpos.hh index 5aedda4eb..e57332a2e 100644 --- a/src/hb-ot-layout-gsubgpos.hh +++ b/src/hb-ot-layout-gsubgpos.hh @@ -3544,6 +3544,18 @@ struct ChainRuleSet { if (unsafe_to == (unsigned) -1) unsafe_to = unsafe_to1; + + if (lenP1 > 1) + { + // Skip ahead to next possible first glyph match. + for (; i + 1 < num_rules; i++) + { + const auto &r2 = this+rule.arrayZ[i + 1]; + const auto &input2 = StructAfter (r2.backtrack); + if (input2.lenP1 <= 1 || input2.arrayZ[0] != input.arrayZ[0]) + break; + } + } } } if (likely (unsafe_to != (unsigned) -1))