From f2c980be2998a909486a4a40515763a57b03846b Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Sat, 3 Dec 2022 14:49:38 -0700 Subject: [PATCH] [VarData] Optimize wordCount calculation 6% speedup in RobotoFlex-Variable/900 benchmark. --- src/hb-ot-layout-common.hh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/hb-ot-layout-common.hh b/src/hb-ot-layout-common.hh index abc0f2a16..56b98b3e7 100644 --- a/src/hb-ot-layout-common.hh +++ b/src/hb-ot-layout-common.hh @@ -2510,6 +2510,8 @@ struct VarData signed max_threshold = has_long ? +65535 : +127; for (r = 0; r < ri_count; r++) { + bool short_circuit = src->longWords () == has_long && src->wordCount () <= r; + delta_sz[r] = kZero; for (unsigned int i = 0; i < inner_map.get_next_value (); i++) { @@ -2522,7 +2524,11 @@ struct VarData break; } else if (delta != 0) + { delta_sz[r] = kNonWord; + if (short_circuit) + break; + } } }