From 3205de7906abab9d12e614e86e2c182a41420698 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Fri, 27 Oct 2017 15:01:40 -0600 Subject: [PATCH] Make the NullPool HB_INTERNAL shared Saves 2k of .bss section. --- src/hb-open-type-private.hh | 10 ++++++---- src/hb-ot-layout.cc | 3 +++ src/main.cc | 1 + 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/hb-open-type-private.hh b/src/hb-open-type-private.hh index f0ff2ff59..f1c90474a 100644 --- a/src/hb-open-type-private.hh +++ b/src/hb-open-type-private.hh @@ -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 static inline const Type& Null (void) { - static_assert ((sizeof (Type) <= sizeof (_NullPool)), ""); - return *CastP (_NullPool); + static_assert (sizeof (Type) <= HB_NULL_POOL_SIZE, "Increase HB_NULL_POOL_SIZE."); + return *CastP (_hb_NullPool); } /* Specializaiton for arbitrary-content arbitrary-sized Null objects. */ diff --git a/src/hb-ot-layout.cc b/src/hb-ot-layout.cc index 71e782686..4850f720d 100644 --- a/src/hb-ot-layout.cc +++ b/src/hb-ot-layout.cc @@ -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) { diff --git a/src/main.cc b/src/main.cc index 93c3b46af..eb1711ed6 100644 --- a/src/main.cc +++ b/src/main.cc @@ -38,6 +38,7 @@ using namespace OT; +const void *OT::_hb_NullPool[HB_NULL_POOL_SIZE / sizeof (void *)]; int main (int argc, char **argv)