From 99db06b4d2fa420f46dceccd4c9a625d5325d8b3 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Mon, 26 Jun 2023 17:30:31 -0600 Subject: [PATCH] [var] Simplify a couple of copy operations --- src/hb-ot-var-common.hh | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/src/hb-ot-var-common.hh b/src/hb-ot-var-common.hh index 0c14af683..c28962103 100644 --- a/src/hb-ot-var-common.hh +++ b/src/hb-ot-var-common.hh @@ -36,18 +36,14 @@ struct DeltaSetIndexMapFormat01 { friend struct DeltaSetIndexMap; + unsigned get_size () const + { return min_size + mapCount * get_width (); } + private: DeltaSetIndexMapFormat01* copy (hb_serialize_context_t *c) const { TRACE_SERIALIZE (this); - auto *out = c->start_embed (this); - - unsigned total_size = min_size + mapCount * get_width (); - HBUINT8 *p = c->allocate_size (total_size, false); - if (unlikely (!p)) return_trace (nullptr); - - hb_memcpy (p, this, HBUINT8::static_size * total_size); - return_trace (out); + return_trace (c->embed (this)); } template @@ -434,13 +430,7 @@ struct byte_data_t explicit operator bool () const { return bytes.length; } void copy (hb_serialize_context_t *c) const - { - if (unlikely (!bytes.length || !bytes.arrayZ)) return; - - char* ret = c->allocate_size (bytes.length, false); - if (unlikely (!ret)) return; - hb_memcpy (ret, bytes.arrayZ, bytes.length); - } + { c->embed (bytes.arrayZ, bytes.length); } }; enum packed_delta_flag_t