From 71aa10a3942081f2c4ce0c2c5d4c3897d13d887c Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Wed, 18 May 2022 11:37:24 -0600 Subject: [PATCH] [subset-cff] Manually grow vector to avoid memset overhead --- src/hb-subset-cff-common.hh | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/hb-subset-cff-common.hh b/src/hb-subset-cff-common.hh index 2aeed8506..38b2731af 100644 --- a/src/hb-subset-cff-common.hh +++ b/src/hb-subset-cff-common.hh @@ -110,12 +110,10 @@ struct str_encoder_t void copy_str (const hb_ubytes_t &str) { unsigned int offset = buff.length; - if (unlikely (!buff.resize (offset + str.length))) - { - set_error (); - return; - } - if (unlikely (buff.length < offset + str.length)) + /* Manually resize buffer since faster. */ + if ((signed) (buff.length + str.length) <= buff.allocated) + buff.length += str.length; + else if (unlikely (!buff.resize (offset + str.length))) { set_error (); return;