[HarfBuzz] harfbuzz: Branch 'master' - 2 commits

Behdad Esfahbod behdad at kemper.freedesktop.org
Sat Feb 10 20:20:57 UTC 2018


 src/hb-ot-cmap-table.hh |    8 ++++----
 src/hb-subset-glyf.cc   |    9 ++++-----
 src/hb-subset-plan.cc   |   23 +++++++++++------------
 src/hb-subset-plan.hh   |    9 +++------
 4 files changed, 22 insertions(+), 27 deletions(-)

New commits:
commit c31fcf4c58d96eb7d9781a986991b1a79ac7be44
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Sat Feb 10 14:20:10 2018 -0600

    [subset] Replace auto_array with prealloced_array
    
    auto_array has constructor/destructor. Cannot be used in POD object, as the clang
    bots all noticed...

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<hb_codepoint_t> &codepoints,
-                              hb_auto_array_t<CmapSubtableLongGroup> *groups) const
+  inline void populate_groups(hb_prealloced_array_t<hb_codepoint_t> &codepoints,
+                              hb_prealloced_array_t<CmapSubtableLongGroup> *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<CmapSubtableLongGroup> &groups,
+  hb_bool_t _subset (hb_prealloced_array_t<CmapSubtableLongGroup> &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<CmapSubtableLongGroup> groups;
+    hb_prealloced_array_t<CmapSubtableLongGroup> 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<unsigned int> &glyph_ids,
+                                     hb_prealloced_array_t<unsigned int> &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<unsigned int> &glyph_ids,
+                            hb_prealloced_array_t<unsigned int> &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<hb_codepoint_t>&glyphs_to_retain,
+                          hb_prealloced_array_t<hb_codepoint_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<hb_codepoint_t>& plan_codepoints)
+                      hb_prealloced_array_t<hb_codepoint_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<hb_codepoint_t>& codepoints,
-                          hb_auto_array_t<hb_codepoint_t>& old_gids,
-                          hb_auto_array_t<hb_codepoint_t>& old_gids_sorted)
+                          hb_prealloced_array_t<hb_codepoint_t>& codepoints,
+                          hb_prealloced_array_t<hb_codepoint_t>& old_gids,
+                          hb_prealloced_array_t<hb_codepoint_t>& old_gids_sorted)
 {
   OT::cmap::accelerator_t cmap;
   cmap.init (face);
 
-  hb_auto_array_t<unsigned int> bad_indices;
+  hb_prealloced_array_t<unsigned int> 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<hb_subset_plan_t> ();
+
+  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<hb_subset_plan_t> ();
-  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<hb_codepoint_t> codepoints;
-  hb_auto_array_t<hb_codepoint_t> gids_to_retain;
-  hb_auto_array_t<hb_codepoint_t> gids_to_retain_sorted;
+  hb_prealloced_array_t<hb_codepoint_t> codepoints;
+  hb_prealloced_array_t<hb_codepoint_t> gids_to_retain;
+  hb_prealloced_array_t<hb_codepoint_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);
 
commit 931d67900ee6d96b5962a475c1b71a58b821bcba
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Sat Feb 10 14:11:16 2018 -0600

    Fix some other bots

diff --git a/src/hb-subset-glyf.cc b/src/hb-subset-glyf.cc
index e4f55728..6a2fedf6 100644
--- a/src/hb-subset-glyf.cc
+++ b/src/hb-subset-glyf.cc
@@ -84,10 +84,9 @@ _write_glyf_and_loca_prime (const OT::glyf::accelerator_t &glyf,
 {
   char *glyf_prime_data_next = glyf_prime_data;
 
-  hb_codepoint_t next_glyph = -1;
   hb_codepoint_t new_glyph_id = 0;
 
-  unsigned int end_offset;
+  unsigned int end_offset = 0;
   for (unsigned int i = 0; i < glyph_ids.len; i++) {
     unsigned int start_offset;
     if (unlikely (!glyf.get_offsets (glyph_ids[i], &start_offset, &end_offset))) {
@@ -113,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<unsigned int>  &glyphs_to_retain,
+                          hb_auto_array_t<hb_codepoint_t>&glyphs_to_retain,
                           bool                           *use_short_loca,
                           hb_blob_t                     **glyf_prime /* OUT */,
                           hb_blob_t                     **loca_prime /* OUT */)


More information about the HarfBuzz mailing list