[gvar] Refactor deltas array access

This commit is contained in:
Behdad Esfahbod 2022-11-22 13:24:39 -07:00
parent c34c77698c
commit a02317238a
1 changed files with 10 additions and 8 deletions

View File

@ -618,20 +618,22 @@ struct gvar
{ {
unsigned int pt_index = apply_to_all ? i : indices[i]; unsigned int pt_index = apply_to_all ? i : indices[i];
if (unlikely (pt_index >= deltas.length)) continue; if (unlikely (pt_index >= deltas.length)) continue;
ref_points += !deltas.arrayZ[pt_index].flag; auto &delta = deltas.arrayZ[pt_index];
deltas.arrayZ[pt_index].flag = 1; /* this point is referenced, i.e., explicit deltas specified */ ref_points += !delta.flag;
deltas.arrayZ[pt_index].x += x_deltas.arrayZ[i] * scalar; delta.flag = 1; /* this point is referenced, i.e., explicit deltas specified */
deltas.arrayZ[pt_index].y += y_deltas.arrayZ[i] * scalar; delta.x += x_deltas.arrayZ[i] * scalar;
delta.y += y_deltas.arrayZ[i] * scalar;
} }
else else
for (unsigned int i = 0; i < num_deltas; i++) for (unsigned int i = 0; i < num_deltas; i++)
{ {
unsigned int pt_index = apply_to_all ? i : indices[i]; unsigned int pt_index = apply_to_all ? i : indices[i];
if (unlikely (pt_index >= deltas.length)) continue; if (unlikely (pt_index >= deltas.length)) continue;
ref_points += !deltas.arrayZ[pt_index].flag; auto &delta = deltas.arrayZ[pt_index];
deltas.arrayZ[pt_index].flag = 1; /* this point is referenced, i.e., explicit deltas specified */ ref_points += !delta.flag;
deltas.arrayZ[pt_index].x += x_deltas.arrayZ[i]; delta.flag = 1; /* this point is referenced, i.e., explicit deltas specified */
deltas.arrayZ[pt_index].y += y_deltas.arrayZ[i]; delta.x += x_deltas.arrayZ[i];
delta.y += y_deltas.arrayZ[i];
} }
/* infer deltas for unreferenced points */ /* infer deltas for unreferenced points */