From c5a5334aeabecbf5c1576b2fff2862faeed8140e Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Sun, 23 Nov 2025 20:59:48 -0700 Subject: [PATCH] [TupleValues] Micro-optimize The compiler was using a memset here, but I think it was also emitting one conditional (checking i <= stop to begin with). We know that condition is always true. This shows a measurable 1 or 2 percent speedup for me in a mega benchmark of Google Sans Flex. --- src/hb-open-type.hh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/hb-open-type.hh b/src/hb-open-type.hh index acc44a476..2217bb2b7 100644 --- a/src/hb-open-type.hh +++ b/src/hb-open-type.hh @@ -1739,8 +1739,8 @@ struct TupleValues if ((control & VALUES_SIZE_MASK) == VALUES_ARE_ZEROS) { - for (; i < stop; i++) - values.arrayZ[i] = 0; + hb_memset (&values.arrayZ[i], 0, (stop - i) * sizeof (T)); + i = stop; } else if ((control & VALUES_SIZE_MASK) == VALUES_ARE_WORDS) {