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

Behdad Esfahbod behdad at kemper.freedesktop.org
Sat Jun 2 00:30:13 UTC 2018


 src/hb-map-private.hh |   53 --------------------------------------------------
 src/hb-private.hh     |    2 +
 src/hb-set-private.hh |    4 +--
 src/hb-static.cc      |   51 ++++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 56 insertions(+), 54 deletions(-)

New commits:
commit 4f76f956bb3a95b307322cdad4f8d3b97851678e
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Fri Jun 1 17:28:47 2018 -0700

    [map] Move prime_for to hb-static

diff --git a/src/hb-map-private.hh b/src/hb-map-private.hh
index cad6f0e2..7f6b02c5 100644
--- a/src/hb-map-private.hh
+++ b/src/hb-map-private.hh
@@ -39,49 +39,6 @@ inline uint32_t Hash (const T &v)
 }
 
 
-/* Following comment and table copied from glib. */
-/* Each table size has an associated prime modulo (the first prime
- * lower than the table size) used to find the initial bucket. Probing
- * then works modulo 2^n. The prime modulo is necessary to get a
- * good distribution with poor hash functions.
- */
-static const unsigned int prime_mod [] =
-{
-  1,          /* For 1 << 0 */
-  2,
-  3,
-  7,
-  13,
-  31,
-  61,
-  127,
-  251,
-  509,
-  1021,
-  2039,
-  4093,
-  8191,
-  16381,
-  32749,
-  65521,      /* For 1 << 16 */
-  131071,
-  262139,
-  524287,
-  1048573,
-  2097143,
-  4194301,
-  8388593,
-  16777213,
-  33554393,
-  67108859,
-  134217689,
-  268435399,
-  536870909,
-  1073741789,
-  2147483647  /* For 1 << 31 */
-};
-
-
 /*
  * hb_map_t
  */
@@ -148,7 +105,7 @@ struct hb_map_t
     /* Switch to new, empty, array. */
     population = occupancy = 0;
     mask = new_size - 1;
-    prime = prime_for (power);
+    prime = _hb_prime_for (power);
     items = new_items;
 
     /* Insert back old items. */
@@ -226,14 +183,6 @@ struct hb_map_t
 
   protected:
 
-  static inline unsigned int prime_for (unsigned int shift)
-  {
-    if (unlikely (shift >= ARRAY_LENGTH (prime_mod)))
-      return prime_mod[ARRAY_LENGTH (prime_mod) - 1];
-
-    return prime_mod[shift];
-  }
-
   inline unsigned int bucket_for (hb_codepoint_t key) const
   {
     unsigned int i = Hash (key) % prime;
diff --git a/src/hb-private.hh b/src/hb-private.hh
index 74045d7e..e96af550 100644
--- a/src/hb-private.hh
+++ b/src/hb-private.hh
@@ -1231,5 +1231,7 @@ round (double x)
 #endif
 
 
+HB_INTERNAL unsigned int _hb_prime_for (unsigned int shift);
+
 
 #endif /* HB_PRIVATE_HH */
diff --git a/src/hb-static.cc b/src/hb-static.cc
index e26e5c80..aa0871d5 100644
--- a/src/hb-static.cc
+++ b/src/hb-static.cc
@@ -30,3 +30,54 @@
 void * const _hb_NullPool[HB_NULL_POOL_SIZE / sizeof (void *)] = {};
 /*thread_local*/ void * _hb_CrapPool[HB_NULL_POOL_SIZE / sizeof (void *)] = {};
 #endif
+
+
+/* Following comment and table copied from glib. */
+/* Each table size has an associated prime modulo (the first prime
+ * lower than the table size) used to find the initial bucket. Probing
+ * then works modulo 2^n. The prime modulo is necessary to get a
+ * good distribution with poor hash functions.
+ */
+static const unsigned int prime_mod [] =
+{
+  1,          /* For 1 << 0 */
+  2,
+  3,
+  7,
+  13,
+  31,
+  61,
+  127,
+  251,
+  509,
+  1021,
+  2039,
+  4093,
+  8191,
+  16381,
+  32749,
+  65521,      /* For 1 << 16 */
+  131071,
+  262139,
+  524287,
+  1048573,
+  2097143,
+  4194301,
+  8388593,
+  16777213,
+  33554393,
+  67108859,
+  134217689,
+  268435399,
+  536870909,
+  1073741789,
+  2147483647  /* For 1 << 31 */
+};
+
+unsigned int _hb_prime_for (unsigned int shift)
+{
+  if (unlikely (shift >= ARRAY_LENGTH (prime_mod)))
+    return prime_mod[ARRAY_LENGTH (prime_mod) - 1];
+
+  return prime_mod[shift];
+}
commit 33d6f46bbbb4fdee110f1cb024a37ed2e46e5e22
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Fri Jun 1 17:25:35 2018 -0700

    [set] Shrink page-map size again

diff --git a/src/hb-set-private.hh b/src/hb-set-private.hh
index 71688157..9afa3d90 100644
--- a/src/hb-set-private.hh
+++ b/src/hb-set-private.hh
@@ -158,7 +158,7 @@ struct hb_set_t
     }
 
     typedef unsigned long long elt_t;
-    static const unsigned int PAGE_BITS = 1024;
+    static const unsigned int PAGE_BITS = 512;
     static_assert ((PAGE_BITS & ((PAGE_BITS) - 1)) == 0, "");
 
     static inline unsigned int elt_get_min (const elt_t &elt) { return _hb_ctz (elt); }
@@ -183,7 +183,7 @@ struct hb_set_t
   hb_object_header_t header;
   bool successful; /* Allocations successful */
   mutable unsigned int population;
-  hb_vector_t<page_map_t, 8> page_map;
+  hb_vector_t<page_map_t, 1> page_map;
   hb_vector_t<page_t, 1> pages;
 
   inline void init_shallow (void)


More information about the HarfBuzz mailing list