From 6d7206b68bbb4cd99f2a53ff8ac61114d272a958 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Tue, 22 Nov 2022 10:13:14 -0700 Subject: [PATCH] [gvar] Optimize unpack_deltas --- src/hb-ot-var-gvar-table.hh | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/hb-ot-var-gvar-table.hh b/src/hb-ot-var-gvar-table.hh index e00da1ff8..ab53f0c10 100644 --- a/src/hb-ot-var-gvar-table.hh +++ b/src/hb-ot-var-gvar-table.hh @@ -342,20 +342,24 @@ struct GlyphVariationData unsigned int j; if (control & DELTAS_ARE_ZERO) for (j = 0; j < run_count && i < count; j++, i++) - deltas[i] = 0; + 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 && i < count; j++, i++) { - if (unlikely (p + HBUINT16::static_size > end)) return false; - deltas[i] = *(const HBINT16 *) p; + deltas.arrayZ[i] = * (const HBINT16 *) p; p += HBUINT16::static_size; } + } else + { + if (unlikely (p + run_count > end)) return false; for (j = 0; j < run_count && i < count; j++, i++) { - if (unlikely (p + 1 > end)) return false; - deltas[i] = *(const HBINT8 *) p++; + deltas.arrayZ[i] = * (const HBINT8 *) p++; } + } if (j < run_count) return false; }