From 7a3928e2b6099c5c334ca0b2469a567b529bcf34 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Mon, 24 Apr 2023 17:38:20 -0600 Subject: [PATCH] [var] Optimize calculate_scalar For varfonts with lots of deltasets, the loop in this function is *really* hot... --- src/hb-ot-var-common.hh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/hb-ot-var-common.hh b/src/hb-ot-var-common.hh index 2081f1b9b..a4b322999 100644 --- a/src/hb-ot-var-common.hh +++ b/src/hb-ot-var-common.hh @@ -260,7 +260,7 @@ struct TupleVariationHeader else { unsigned int index = get_index (); - if (unlikely (index * coord_count >= shared_tuples.length)) + if (unlikely ((index + 1) * coord_count > shared_tuples.length)) return 0.f; peak_tuple = shared_tuples.sub_array (coord_count * index, coord_count); } @@ -277,13 +277,13 @@ struct TupleVariationHeader for (unsigned int i = 0; i < coord_count; i++) { int v = coords[i]; - int peak = peak_tuple[i].to_int (); + int peak = peak_tuple.arrayZ[i].to_int (); if (!peak || v == peak) continue; if (has_intermediate ()) { - int start = start_tuple[i].to_int (); - int end = end_tuple[i].to_int (); + int start = start_tuple.arrayZ[i].to_int (); + int end = end_tuple.arrayZ[i].to_int (); if (unlikely (start > peak || peak > end || (start < 0 && end > 0 && peak))) continue; if (v < start || v > end) return 0.f;