[PairPos] Optimize get_effective_value_format

Speeds up BM_subset/subset_glyphs/SourceHanSans-Regular_subset.otf/nohinting/512
12%.
This commit is contained in:
Behdad Esfahbod 2022-11-28 14:23:49 -07:00
parent 3131aecf9f
commit 3e151139a8
2 changed files with 8 additions and 1 deletions

View File

@ -189,6 +189,9 @@ struct PairPosFormat1_3
} }
record = &StructAtOffset<const PairValueRecord> (record, record_size); record = &StructAtOffset<const PairValueRecord> (record, record_size);
} }
if (format1 == valueFormat[0] && format2 == valueFormat[1])
break;
} }
return hb_pair (format1, format2); return hb_pair (format1, format2);

View File

@ -322,6 +322,7 @@ struct PairPosFormat2_4
{ {
unsigned len1 = valueFormat1.get_len (); unsigned len1 = valueFormat1.get_len ();
unsigned len2 = valueFormat2.get_len (); unsigned len2 = valueFormat2.get_len ();
unsigned record_size = len1 + len2;
unsigned format1 = 0; unsigned format1 = 0;
unsigned format2 = 0; unsigned format2 = 0;
@ -330,10 +331,13 @@ struct PairPosFormat2_4
{ {
for (unsigned class2_idx : + hb_range ((unsigned) class2Count) | hb_filter (klass2_map)) 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]); format1 = format1 | valueFormat1.get_effective_format (&values[idx]);
format2 = format2 | valueFormat2.get_effective_format (&values[idx + len1]); format2 = format2 | valueFormat2.get_effective_format (&values[idx + len1]);
} }
if (format1 == valueFormat1 && format2 == valueFormat2)
break;
} }
return hb_pair (format1, format2); return hb_pair (format1, format2);