From da2e2c8c25b45cadcebd814a3f42e3d32c4b5e93 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Thu, 8 Jun 2023 17:16:53 -0600 Subject: [PATCH] [subset/cff] Speed up offset writing --- src/hb-ot-cff-common.hh | 52 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/src/hb-ot-cff-common.hh b/src/hb-ot-cff-common.hh index 7b0a7e2d6..fb548b2e1 100644 --- a/src/hb-ot-cff-common.hh +++ b/src/hb-ot-cff-common.hh @@ -109,6 +109,7 @@ struct CFFIndex /* serialize indices */ unsigned int offset = 1; +#ifdef HB_OPTIMIZE_SIZE unsigned int i = 0; for (unsigned _ : +it) { @@ -116,6 +117,57 @@ struct CFFIndex offset += _; } set_offset_at (i, offset); +#else + switch (off_size) + { + case 1: + { + HBUINT8 *p = (HBUINT8 *) offsets; + for (unsigned _ : +it) + { + *p++ = offset; + offset += _; + } + *p = offset; + } + break; + case 2: + { + HBUINT16 *p = (HBUINT16 *) offsets; + for (unsigned _ : +it) + { + *p++ = offset; + offset += _; + } + *p = offset; + } + break; + case 3: + { + HBUINT24 *p = (HBUINT24 *) offsets; + for (unsigned _ : +it) + { + *p++ = offset; + offset += _; + } + *p = offset; + } + break; + case 4: + { + HBUINT32 *p = (HBUINT32 *) offsets; + for (unsigned _ : +it) + { + *p++ = offset; + offset += _; + } + *p = offset; + } + break; + default: + break; + } +#endif return_trace (total); }