Make the NullPool HB_INTERNAL shared

Saves 2k of .bss section.
This commit is contained in:
Behdad Esfahbod 2017-10-27 15:01:40 -06:00
parent 7036f1d22c
commit 3205de7906
3 changed files with 10 additions and 4 deletions

View 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. */

View 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)
{

View 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)