From 3e151139a8987a13cdd8cc2ddc025534c51c607f Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Mon, 28 Nov 2022 14:23:49 -0700 Subject: [PATCH] [PairPos] Optimize get_effective_value_format Speeds up BM_subset/subset_glyphs/SourceHanSans-Regular_subset.otf/nohinting/512 12%. --- src/OT/Layout/GPOS/PairPosFormat1.hh | 3 +++ src/OT/Layout/GPOS/PairPosFormat2.hh | 6 +++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/OT/Layout/GPOS/PairPosFormat1.hh b/src/OT/Layout/GPOS/PairPosFormat1.hh index 014cfdaf7..69dad4b9b 100644 --- a/src/OT/Layout/GPOS/PairPosFormat1.hh +++ b/src/OT/Layout/GPOS/PairPosFormat1.hh @@ -189,6 +189,9 @@ struct PairPosFormat1_3 } record = &StructAtOffset (record, record_size); } + + if (format1 == valueFormat[0] && format2 == valueFormat[1]) + break; } return hb_pair (format1, format2); diff --git a/src/OT/Layout/GPOS/PairPosFormat2.hh b/src/OT/Layout/GPOS/PairPosFormat2.hh index 85b0eac8e..9c87ac2b0 100644 --- a/src/OT/Layout/GPOS/PairPosFormat2.hh +++ b/src/OT/Layout/GPOS/PairPosFormat2.hh @@ -322,6 +322,7 @@ struct PairPosFormat2_4 { unsigned len1 = valueFormat1.get_len (); unsigned len2 = valueFormat2.get_len (); + unsigned record_size = len1 + len2; unsigned format1 = 0; unsigned format2 = 0; @@ -330,10 +331,13 @@ struct PairPosFormat2_4 { for (unsigned class2_idx : + hb_range ((unsigned) class2Count) | hb_filter (klass2_map)) { - unsigned idx = (class1_idx * (unsigned) class2Count + class2_idx) * (len1 + len2); + unsigned idx = (class1_idx * (unsigned) class2Count + class2_idx) * record_size; format1 = format1 | valueFormat1.get_effective_format (&values[idx]); format2 = format2 | valueFormat2.get_effective_format (&values[idx + len1]); } + + if (format1 == valueFormat1 && format2 == valueFormat2) + break; } return hb_pair (format1, format2);