[gvar] minor

This commit is contained in:
Ebrahim Byagowi 2019-10-05 23:58:52 +03:30
parent 5752863640
commit 21c80d955f
1 changed files with 21 additions and 22 deletions

View File

@ -306,7 +306,7 @@ struct GlyphVarData
uint16_t count = *p++; uint16_t count = *p++;
if (count & POINTS_ARE_WORDS) if (count & POINTS_ARE_WORDS)
{ {
if (!check.in_range (p)) return false; if (unlikely (!check.in_range (p))) return false;
count = ((count & POINT_RUN_COUNT_MASK) << 8) | *p++; count = ((count & POINT_RUN_COUNT_MASK) << 8) | *p++;
} }
points.resize (count); points.resize (count);
@ -315,7 +315,7 @@ struct GlyphVarData
uint16_t i = 0; uint16_t i = 0;
while (i < count) while (i < count)
{ {
if (!check.in_range (p)) return false; if (unlikely (!check.in_range (p))) return false;
uint16_t j; uint16_t j;
uint8_t control = *p++; uint8_t control = *p++;
uint16_t run_count = (control & POINT_RUN_COUNT_MASK) + 1; uint16_t run_count = (control & POINT_RUN_COUNT_MASK) + 1;
@ -323,7 +323,8 @@ struct GlyphVarData
{ {
for (j = 0; j < run_count && i < count; j++, i++) for (j = 0; j < run_count && i < count; j++, i++)
{ {
if (!check.in_range ((const HBUINT16 *)p)) return false; if (unlikely (!check.in_range ((const HBUINT16 *) p)))
return false;
n += *(const HBUINT16 *)p; n += *(const HBUINT16 *)p;
points[i] = n; points[i] = n;
p += HBUINT16::static_size; p += HBUINT16::static_size;
@ -333,7 +334,7 @@ struct GlyphVarData
{ {
for (j = 0; j < run_count && i < count; j++, i++) for (j = 0; j < run_count && i < count; j++, i++)
{ {
if (!check.in_range (p)) return false; if (unlikely (!check.in_range (p))) return false;
n += *p++; n += *p++;
points[i] = n; points[i] = n;
} }
@ -358,7 +359,7 @@ struct GlyphVarData
unsigned int count = deltas.length; unsigned int count = deltas.length;
while (i < count) while (i < count)
{ {
if (!check.in_range (p)) return false; if (unlikely (!check.in_range (p))) return false;
uint8_t control = *p++; uint8_t control = *p++;
unsigned int run_count = (control & DELTA_RUN_COUNT_MASK) + 1; unsigned int run_count = (control & DELTA_RUN_COUNT_MASK) + 1;
unsigned int j; unsigned int j;
@ -368,7 +369,7 @@ struct GlyphVarData
else if (control & DELTAS_ARE_WORDS) else if (control & DELTAS_ARE_WORDS)
for (j = 0; j < run_count && i < count; j++, i++) for (j = 0; j < run_count && i < count; j++, i++)
{ {
if (!check.in_range ((const HBUINT16 *)p)) if (unlikely (!check.in_range ((const HBUINT16 *) p)))
return false; return false;
deltas[i] = *(const HBINT16 *) p; deltas[i] = *(const HBINT16 *) p;
p += HBUINT16::static_size; p += HBUINT16::static_size;
@ -376,7 +377,7 @@ struct GlyphVarData
else else
for (j = 0; j < run_count && i < count; j++, i++) for (j = 0; j < run_count && i < count; j++, i++)
{ {
if (!check.in_range (p)) if (unlikely (!check.in_range (p)))
return false; return false;
deltas[i] = *(const HBINT8 *) p++; deltas[i] = *(const HBINT8 *) p++;
} }
@ -523,8 +524,6 @@ struct gvar
{ {
void init (hb_face_t *face) void init (hb_face_t *face)
{ {
memset (this, 0, sizeof (accelerator_t));
gvar_table = hb_sanitize_context_t ().reference_table<gvar> (face); gvar_table = hb_sanitize_context_t ().reference_table<gvar> (face);
hb_blob_ptr_t<fvar> fvar_table = hb_sanitize_context_t ().reference_table<fvar> (face); hb_blob_ptr_t<fvar> fvar_table = hb_sanitize_context_t ().reference_table<fvar> (face);
unsigned int axis_count = fvar_table->get_axis_count (); unsigned int axis_count = fvar_table->get_axis_count ();