Make the NullPool HB_INTERNAL shared
authorBehdad Esfahbod <behdad@behdad.org>
Fri, 27 Oct 2017 21:01:40 +0000 (15:01 -0600)
committerBehdad Esfahbod <behdad@behdad.org>
Fri, 27 Oct 2017 21:01:40 +0000 (15:01 -0600)
Saves 2k of .bss section.

src/hb-open-type-private.hh
src/hb-ot-layout.cc
src/main.cc

index f0ff2ff59001ce335f0cd5844ff6f544e1e62f14..f1c90474a5ee6de51e10543129b2a5d0e5c0a81f 100644 (file)
@@ -130,14 +130,16 @@ static inline Type& StructAfter(TObject &X)
  */
 
 /* Global nul-content Null pool.  Enlarge as necessary. */
-/* TODO This really should be a extern HB_INTERNAL and defined somewhere... */
-static const void *_NullPool[(256+8) / sizeof (void *)];
+
+#define HB_NULL_POOL_SIZE 264
+static_assert (HB_NULL_POOL_SIZE % sizeof (void *) == 0, "Align HB_NULL_POOL_SIZE.");
+extern HB_INTERNAL const void *_hb_NullPool[HB_NULL_POOL_SIZE / sizeof (void *)];
 
 /* Generic nul-content Null objects. */
 template <typename Type>
 static inline const Type& Null (void) {
-  static_assert ((sizeof (Type) <= sizeof (_NullPool)), "");
-  return *CastP<Type> (_NullPool);
+  static_assert (sizeof (Type) <= HB_NULL_POOL_SIZE, "Increase HB_NULL_POOL_SIZE.");
+  return *CastP<Type> (_hb_NullPool);
 }
 
 /* Specializaiton for arbitrary-content arbitrary-sized Null objects. */
index 71e782686c75e31160667a77ba3f9a667c10c644..4850f720d83107d5f64733e356eaa77d2da8a706 100644 (file)
@@ -39,6 +39,9 @@
 #include "hb-ot-map-private.hh"
 
 
+const void *OT::_hb_NullPool[HB_NULL_POOL_SIZE / sizeof (void *)];
+
+
 hb_ot_layout_t *
 _hb_ot_layout_create (hb_face_t *face)
 {
index 93c3b46af2cfc823a50535aecbe70f828b41663e..eb1711ed6dc5e2323531f13c25fc4617cbe7a500 100644 (file)
@@ -38,6 +38,7 @@
 
 using namespace OT;
 
+const void *OT::_hb_NullPool[HB_NULL_POOL_SIZE / sizeof (void *)];
 
 int
 main (int argc, char **argv)