From bb3bb76450c575321aecf33b74e5b51d0c5c75e3 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Tue, 22 Nov 2022 11:53:35 -0700 Subject: [PATCH] [gvar] Optimize scalar = 1.0 case --- src/hb-ot-var-gvar-table.hh | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/src/hb-ot-var-gvar-table.hh b/src/hb-ot-var-gvar-table.hh index 34e505662..5618b56cd 100644 --- a/src/hb-ot-var-gvar-table.hh +++ b/src/hb-ot-var-gvar-table.hh @@ -609,14 +609,24 @@ struct gvar hb_memset (deltas.arrayZ, 0, deltas.length * sizeof (deltas.arrayZ[0])); - for (unsigned int i = 0; i < num_deltas; i++) - { - unsigned int pt_index = apply_to_all ? i : indices[i]; - if (unlikely (pt_index >= deltas.length)) continue; - deltas.arrayZ[pt_index].flag = 1; /* this point is referenced, i.e., explicit deltas specified */ - deltas.arrayZ[pt_index].x += x_deltas.arrayZ[i] * scalar; - deltas.arrayZ[pt_index].y += y_deltas.arrayZ[i] * scalar; - } + if (scalar != 1.0f) + for (unsigned int i = 0; i < num_deltas; i++) + { + unsigned int pt_index = apply_to_all ? i : indices[i]; + if (unlikely (pt_index >= deltas.length)) continue; + deltas.arrayZ[pt_index].flag = 1; /* this point is referenced, i.e., explicit deltas specified */ + deltas.arrayZ[pt_index].x += x_deltas.arrayZ[i] * scalar; + deltas.arrayZ[pt_index].y += y_deltas.arrayZ[i] * scalar; + } + else + for (unsigned int i = 0; i < num_deltas; i++) + { + unsigned int pt_index = apply_to_all ? i : indices[i]; + if (unlikely (pt_index >= deltas.length)) continue; + deltas.arrayZ[pt_index].flag = 1; /* this point is referenced, i.e., explicit deltas specified */ + deltas.arrayZ[pt_index].x += x_deltas.arrayZ[i]; + deltas.arrayZ[pt_index].y += y_deltas.arrayZ[i]; + } /* infer deltas for unreferenced points */ unsigned start_point = 0;