[var] Optimize calculate_scalar

For varfonts with lots of deltasets, the loop in this function is
*really* hot...
This commit is contained in:
Behdad Esfahbod committed 2023-04-24 17:38:20 -06:00
1 parent 8929603631
commit 7a3928e2b6
1 file changed
+4 -4
+4 -4
View File
@@ -260,7 +260,7 @@ struct TupleVariationHeader
else
{
unsigned int index = get_index ();
if (unlikely (index * coord_count >= shared_tuples.length))
if (unlikely ((index + 1) * coord_count > shared_tuples.length))
return 0.f;
peak_tuple = shared_tuples.sub_array (coord_count * index, coord_count);
}
@@ -277,13 +277,13 @@ struct TupleVariationHeader
for (unsigned int i = 0; i < coord_count; i++)
{
int v = coords[i];
int peak = peak_tuple[i].to_int ();
int peak = peak_tuple.arrayZ[i].to_int ();
if (!peak || v == peak) continue;
if (has_intermediate ())
{
int start = start_tuple[i].to_int ();
int end = end_tuple[i].to_int ();
int start = start_tuple.arrayZ[i].to_int ();
int end = end_tuple.arrayZ[i].to_int ();
if (unlikely (start > peak || peak > end ||
(start < 0 && end > 0 && peak))) continue;
if (v < start || v > end) return 0.f;