[gvar] Optimize unpack_points

This commit is contained in:
Behdad Esfahbod 2022-11-22 10:16:21 -07:00
parent 6d7206b68b
commit a2059f8f55
1 changed files with 4 additions and 4 deletions

View File

@ -299,21 +299,21 @@ struct GlyphVariationData
uint16_t run_count = (control & POINT_RUN_COUNT_MASK) + 1; uint16_t run_count = (control & POINT_RUN_COUNT_MASK) + 1;
if (control & POINTS_ARE_WORDS) if (control & POINTS_ARE_WORDS)
{ {
if (unlikely (p + run_count * HBUINT16::static_size > end)) return false;
for (j = 0; j < run_count && i < count; j++, i++) for (j = 0; j < run_count && i < count; j++, i++)
{ {
if (unlikely (p + HBUINT16::static_size > end)) return false;
n += *(const HBUINT16 *)p; n += *(const HBUINT16 *)p;
points[i] = n; points.arrayZ[i] = n;
p += HBUINT16::static_size; p += HBUINT16::static_size;
} }
} }
else else
{ {
if (unlikely (p + run_count > end)) return false;
for (j = 0; j < run_count && i < count; j++, i++) for (j = 0; j < run_count && i < count; j++, i++)
{ {
if (unlikely (p + 1 > end)) return false;
n += *p++; n += *p++;
points[i] = n; points.arrayZ[i] = n;
} }
} }
if (j < run_count) return false; if (j < run_count) return false;