From d3f90a8ca709f3f1b61484f832303b644ddb8744 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Mon, 26 Jun 2023 14:02:26 -0600 Subject: [PATCH] [subset/cff] Use a typedef for glyph_to_sid_map_t --- src/hb-ot-cff-common.hh | 2 ++ src/hb-ot-cff1-table.hh | 12 ++++++------ src/hb-subset-cff-common.hh | 4 ++-- src/hb-subset-cff1.cc | 8 ++++---- 4 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/hb-ot-cff-common.hh b/src/hb-ot-cff-common.hh index 30ce7b826..f646425fd 100644 --- a/src/hb-ot-cff-common.hh +++ b/src/hb-ot-cff-common.hh @@ -52,8 +52,10 @@ struct code_pair_t hb_codepoint_t glyph; }; + using str_buff_t = hb_vector_t; using str_buff_vec_t = hb_vector_t; +using glyph_to_sid_map_t = hb_vector_t; /* CFF INDEX */ template diff --git a/src/hb-ot-cff1-table.hh b/src/hb-ot-cff1-table.hh index 2ad92979c..2118c4fb7 100644 --- a/src/hb-ot-cff1-table.hh +++ b/src/hb-ot-cff1-table.hh @@ -330,7 +330,7 @@ struct Charset0 return sids[glyph - 1]; } - void collect_glyph_to_sid_map (hb_vector_t *mapping, unsigned int num_glyphs) const + void collect_glyph_to_sid_map (glyph_to_sid_map_t *mapping, unsigned int num_glyphs) const { mapping->resize (num_glyphs, false); for (hb_codepoint_t gid = 1; gid < num_glyphs; gid++) @@ -430,7 +430,7 @@ struct Charset1_2 { return 0; } - void collect_glyph_to_sid_map (hb_vector_t *mapping, unsigned int num_glyphs) const + void collect_glyph_to_sid_map (glyph_to_sid_map_t *mapping, unsigned int num_glyphs) const { mapping->resize (num_glyphs, false); hb_codepoint_t gid = 1; @@ -589,7 +589,7 @@ struct Charset } } - void collect_glyph_to_sid_map (hb_vector_t *mapping, unsigned int num_glyphs) const + void collect_glyph_to_sid_map (glyph_to_sid_map_t *mapping, unsigned int num_glyphs) const { switch (format) { @@ -1268,13 +1268,13 @@ struct cff1 } } - hb_vector_t *create_glyph_to_sid_map () const + glyph_to_sid_map_t *create_glyph_to_sid_map () const { if (charset != &Null (Charset)) { - auto *mapping = (hb_vector_t *) hb_malloc (sizeof (hb_vector_t)); + auto *mapping = (glyph_to_sid_map_t *) hb_malloc (sizeof (glyph_to_sid_map_t)); if (unlikely (!mapping)) return nullptr; - mapping = new (mapping) hb_vector_t (); + mapping = new (mapping) glyph_to_sid_map_t (); mapping->push (0); charset->collect_glyph_to_sid_map (mapping, num_glyphs); return mapping; diff --git a/src/hb-subset-cff-common.hh b/src/hb-subset-cff-common.hh index 6d08a5e0e..f54792648 100644 --- a/src/hb-subset-cff-common.hh +++ b/src/hb-subset-cff-common.hh @@ -517,7 +517,7 @@ struct cff_subset_accelerator_t auto *mapping = glyph_to_sid_map.get_relaxed (); if (mapping) { - mapping->~hb_vector_t (); + mapping->~glyph_to_sid_map_t (); hb_free (mapping); } } @@ -525,7 +525,7 @@ struct cff_subset_accelerator_t parsed_cs_str_vec_t parsed_charstrings; parsed_cs_str_vec_t parsed_global_subrs; hb_vector_t parsed_local_subrs; - mutable hb_atomic_ptr_t> glyph_to_sid_map; + mutable hb_atomic_ptr_t glyph_to_sid_map; private: hb_blob_t* original_blob; diff --git a/src/hb-subset-cff1.cc b/src/hb-subset-cff1.cc index b71db122c..018d2a105 100644 --- a/src/hb-subset-cff1.cc +++ b/src/hb-subset-cff1.cc @@ -519,9 +519,9 @@ struct cff1_subset_plan return; } - hb_vector_t *glyph_to_sid_map = acc.cff_accelerator ? - acc.cff_accelerator->glyph_to_sid_map.get_acquire () : - nullptr; + glyph_to_sid_map_t *glyph_to_sid_map = acc.cff_accelerator ? + acc.cff_accelerator->glyph_to_sid_map.get_acquire () : + nullptr; bool created_map = false; if (!glyph_to_sid_map && acc.cff_accelerator) { @@ -566,7 +566,7 @@ struct cff1_subset_plan if ((!plan->accelerator && acc.cff_accelerator) || !acc.cff_accelerator->glyph_to_sid_map.cmpexch (nullptr, glyph_to_sid_map)) { - glyph_to_sid_map->~hb_vector_t (); + glyph_to_sid_map->~glyph_to_sid_map_t (); hb_free (glyph_to_sid_map); } }