From 04809ede8e5d9943be8a294acecdffe2f0be492f Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Thu, 29 Jun 2023 11:58:53 -0600 Subject: [PATCH] [CompositeGlyph] Micro-optimize translate() --- src/OT/glyf/CompositeGlyph.hh | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/src/OT/glyf/CompositeGlyph.hh b/src/OT/glyf/CompositeGlyph.hh index cb74669c0..fcd21d88a 100644 --- a/src/OT/glyf/CompositeGlyph.hh +++ b/src/OT/glyf/CompositeGlyph.hh @@ -105,9 +105,27 @@ struct CompositeGlyphRecord auto arrayZ = points.arrayZ; unsigned count = points.length; - if (trans.x != 0.f || trans.y != 0.f) - for (unsigned i = 0; i < count; i++) - arrayZ[i].translate (trans); + if (HB_OPTIMIZE_SIZE_VAL) + { + if (trans.x != 0.f || trans.y != 0.f) + for (unsigned i = 0; i < count; i++) + arrayZ[i].translate (trans); + } + else + { + if (trans.x != 0.f && trans.y != 0.f) + for (unsigned i = 0; i < count; i++) + arrayZ[i].translate (trans); + else + { + if (trans.x != 0.f) + for (unsigned i = 0; i < count; i++) + arrayZ[i].x += trans.x; + else if (trans.y != 0.f) + for (unsigned i = 0; i < count; i++) + arrayZ[i].y += trans.y; + } + } } void transform_points (hb_array_t points,