From 76e269af9e87d95415564d75a3aabc2ecec262cd Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Wed, 26 Apr 2023 15:47:12 -0600 Subject: [PATCH] [gvar] Micro-optimize --- src/hb-ot-var-common.hh | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/hb-ot-var-common.hh b/src/hb-ot-var-common.hh index 8e10f162d..4fa41f1b5 100644 --- a/src/hb-ot-var-common.hh +++ b/src/hb-ot-var-common.hh @@ -488,11 +488,10 @@ struct TupleVariationData unsigned control = *p++; unsigned run_count = (control & POINT_RUN_COUNT_MASK) + 1; if (unlikely (i + run_count > count)) return false; - unsigned j; if (control & POINTS_ARE_WORDS) { if (unlikely (p + run_count * HBUINT16::static_size > end)) return false; - for (j = 0; j < run_count; j++, i++) + for (unsigned stop = i + run_count; i < stop; i++) { n += *(const HBUINT16 *)p; points.arrayZ[i] = n; @@ -502,7 +501,7 @@ struct TupleVariationData else { if (unlikely (p + run_count > end)) return false; - for (j = 0; j < run_count; j++, i++) + for (unsigned stop = i + run_count; i < stop; i++) { n += *p++; points.arrayZ[i] = n; @@ -531,16 +530,15 @@ struct TupleVariationData unsigned control = *p++; unsigned run_count = (control & DELTA_RUN_COUNT_MASK) + 1; if (unlikely (i + run_count > count)) return false; - unsigned j; if (control & DELTAS_ARE_ZERO) { - for (j = 0; j < run_count; j++, i++) + for (unsigned stop = i + run_count; i < stop; i++) deltas.arrayZ[i] = 0; } else if (control & DELTAS_ARE_WORDS) { if (unlikely (p + run_count * HBUINT16::static_size > end)) return false; - for (j = 0; j < run_count; j++, i++) + for (unsigned stop = i + run_count; i < stop; i++) { deltas.arrayZ[i] = * (const HBINT16 *) p; p += HBUINT16::static_size; @@ -549,7 +547,7 @@ struct TupleVariationData else { if (unlikely (p + run_count > end)) return false; - for (j = 0; j < run_count; j++, i++) + for (unsigned stop = i + run_count; i < stop; i++) { deltas.arrayZ[i] = * (const HBINT8 *) p++; }