diff --git a/src/hb-ot-cmap-table.hh b/src/hb-ot-cmap-table.hh index daee6ca5a1e5a466d149bc47f57d33d61f7a1de6..70a9f647e20133025a2c521c710c22c7a2405475 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 6a2fedf65d7ee7f2715c67fd77c81f5c3de04952..31358e81ffc91315be940b4875f31c8c30aecbe3 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 247df5c6f8bca9830c82fe30408aa512ba64cf8a..4e71fb6f870111d666f6a6308a8a6dabf709e7e4 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 3943e65bb44b8e1a93b71d11540fe9ea2156b867..410d9beca9d1cb6692afb64919c3b524c428d33b 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);