From c31fcf4c58d96eb7d9781a986991b1a79ac7be44 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Sat, 10 Feb 2018 14:20:10 -0600 Subject: [PATCH] [subset] Replace auto_array with prealloced_array auto_array has constructor/destructor. Cannot be used in POD object, as the clang bots all noticed... --- src/hb-ot-cmap-table.hh | 8 ++++---- src/hb-subset-glyf.cc | 6 +++--- src/hb-subset-plan.cc | 23 +++++++++++------------ src/hb-subset-plan.hh | 9 +++------ 4 files changed, 21 insertions(+), 25 deletions(-) diff --git a/src/hb-ot-cmap-table.hh b/src/hb-ot-cmap-table.hh index daee6ca5..70a9f647 100644 --- a/src/hb-ot-cmap-table.hh +++ b/src/hb-ot-cmap-table.hh @@ -521,8 +521,8 @@ struct cmap encodingRecord.sanitize (c, this)); } - inline void populate_groups(hb_auto_array_t &codepoints, - hb_auto_array_t *groups) const + inline void populate_groups(hb_prealloced_array_t &codepoints, + hb_prealloced_array_t *groups) const { CmapSubtableLongGroup *group = nullptr; for (unsigned int i = 0; i < codepoints.len; i++) { @@ -549,7 +549,7 @@ struct cmap } } - hb_bool_t _subset (hb_auto_array_t &groups, + hb_bool_t _subset (hb_prealloced_array_t &groups, size_t dest_sz, void *dest) const { @@ -591,7 +591,7 @@ struct cmap hb_blob_t * subset (hb_subset_plan_t *plan, hb_face_t *source) const { - hb_auto_array_t groups; + hb_prealloced_array_t groups; populate_groups(plan->codepoints, &groups); diff --git a/src/hb-subset-glyf.cc b/src/hb-subset-glyf.cc index 6a2fedf6..31358e81 100644 --- a/src/hb-subset-glyf.cc +++ b/src/hb-subset-glyf.cc @@ -31,7 +31,7 @@ HB_INTERNAL bool _calculate_glyf_and_loca_prime_size (const OT::glyf::accelerator_t &glyf, - hb_auto_array_t &glyph_ids, + hb_prealloced_array_t &glyph_ids, bool *use_short_loca, /* OUT */ unsigned int *glyf_size, /* OUT */ unsigned int *loca_size /* OUT */) @@ -75,7 +75,7 @@ _write_loca_entry (unsigned int id, unsigned int offset, bool is_short, void *lo HB_INTERNAL bool _write_glyf_and_loca_prime (const OT::glyf::accelerator_t &glyf, const char *glyf_data, - hb_auto_array_t &glyph_ids, + hb_prealloced_array_t &glyph_ids, bool use_short_loca, int glyf_prime_size, char *glyf_prime_data /* OUT */, @@ -112,7 +112,7 @@ _write_glyf_and_loca_prime (const OT::glyf::accelerator_t &glyf, HB_INTERNAL bool _hb_subset_glyf_and_loca (const OT::glyf::accelerator_t &glyf, const char *glyf_data, - hb_auto_array_t&glyphs_to_retain, + hb_prealloced_array_t&glyphs_to_retain, bool *use_short_loca, hb_blob_t **glyf_prime /* OUT */, hb_blob_t **loca_prime /* OUT */) diff --git a/src/hb-subset-plan.cc b/src/hb-subset-plan.cc index 247df5c6..4e71fb6f 100644 --- a/src/hb-subset-plan.cc +++ b/src/hb-subset-plan.cc @@ -51,7 +51,7 @@ hb_subset_plan_new_gid_for_old_id (hb_subset_plan_t *plan, HB_INTERNAL void _populate_codepoints (hb_set_t *input_codepoints, - hb_auto_array_t& plan_codepoints) + hb_prealloced_array_t& plan_codepoints) { plan_codepoints.alloc (hb_set_get_population (input_codepoints)); hb_codepoint_t cp = -1; @@ -64,14 +64,14 @@ _populate_codepoints (hb_set_t *input_codepoints, HB_INTERNAL void _populate_gids_to_retain (hb_face_t *face, - hb_auto_array_t& codepoints, - hb_auto_array_t& old_gids, - hb_auto_array_t& old_gids_sorted) + hb_prealloced_array_t& codepoints, + hb_prealloced_array_t& old_gids, + hb_prealloced_array_t& old_gids_sorted) { OT::cmap::accelerator_t cmap; cmap.init (face); - hb_auto_array_t bad_indices; + hb_prealloced_array_t bad_indices; old_gids.alloc (codepoints.len); bool has_zero = false; @@ -131,6 +131,11 @@ hb_subset_plan_create (hb_face_t *face, hb_subset_input_t *input) { hb_subset_plan_t *plan = hb_object_create (); + + plan->codepoints.init(); + plan->gids_to_retain.init(); + plan->gids_to_retain_sorted.init(); + _populate_codepoints (input->codepoints, plan->codepoints); _populate_gids_to_retain (face, plan->codepoints, @@ -139,13 +144,6 @@ hb_subset_plan_create (hb_face_t *face, return plan; } -hb_subset_plan_t * -hb_subset_plan_get_empty () -{ - hb_subset_plan_t *plan = hb_object_create (); - return plan; -} - /** * hb_subset_plan_destroy: * @@ -159,5 +157,6 @@ hb_subset_plan_destroy (hb_subset_plan_t *plan) plan->codepoints.finish (); plan->gids_to_retain.finish (); plan->gids_to_retain_sorted.finish (); + free (plan); } diff --git a/src/hb-subset-plan.hh b/src/hb-subset-plan.hh index 3943e65b..410d9bec 100644 --- a/src/hb-subset-plan.hh +++ b/src/hb-subset-plan.hh @@ -38,9 +38,9 @@ struct hb_subset_plan_t { // TODO(Q1) actual map, drop this crap // Look at me ma, I'm a poor mans map codepoint : new gid // codepoints is sorted and aligned with gids_to_retain. - hb_auto_array_t codepoints; - hb_auto_array_t gids_to_retain; - hb_auto_array_t gids_to_retain_sorted; + hb_prealloced_array_t codepoints; + hb_prealloced_array_t gids_to_retain; + hb_prealloced_array_t gids_to_retain_sorted; }; typedef struct hb_subset_plan_t hb_subset_plan_t; @@ -55,9 +55,6 @@ hb_subset_plan_new_gid_for_old_id(hb_subset_plan_t *plan, hb_codepoint_t old_gid, hb_codepoint_t *new_gid /* OUT */); -HB_INTERNAL hb_subset_plan_t * -hb_subset_plan_get_empty (); - HB_INTERNAL void hb_subset_plan_destroy (hb_subset_plan_t *plan); -- GitLab