From 28e767ddea3acea744fad3f8e44f1f8f3b4d198d Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Mon, 21 Nov 2022 21:59:51 -0700 Subject: [PATCH] [subset-cff] Really optimize op_str_t / parsed_cs_op_t layout Now parsed_cs_op_t and op_str_t are both 16 bytes. Saves another 7% in SourceHanSans/10000 benchmark. --- src/hb-cff-interp-common.hh | 9 ++++++--- src/hb-subset-cff-common.hh | 5 +++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/hb-cff-interp-common.hh b/src/hb-cff-interp-common.hh index 496762903..6ebf5aa2a 100644 --- a/src/hb-cff-interp-common.hh +++ b/src/hb-cff-interp-common.hh @@ -480,12 +480,15 @@ struct arg_stack_t : cff_stack_t /* an operator prefixed by its operands in a byte string */ struct op_str_t { - /* This used to be a hb_ubytes_t. Using a pointer and length - * saves 8 bytes in the struct. */ + /* This used to have a hb_ubytes_t. Using a pointer and length + * in a particular order, saves 8 bytes in this struct and more + * in our parsed_cs_op_t subclass. */ + const unsigned char *ptr = nullptr; - unsigned length = 0; op_code_t op; + + uint8_t length = 0; }; /* base of OP_SERIALIZER */ diff --git a/src/hb-subset-cff-common.hh b/src/hb-subset-cff-common.hh index df2bc2db2..ff00fd77e 100644 --- a/src/hb-subset-cff-common.hh +++ b/src/hb-subset-cff-common.hh @@ -309,12 +309,13 @@ struct parsed_cs_op_t : op_str_t bool for_skip () const { return skip_flag; } void set_skip () { skip_flag = true; } - unsigned subr_num; - protected: bool drop_flag : 1; bool keep_flag : 1; bool skip_flag : 1; + + public: + uint16_t subr_num; }; struct parsed_cs_str_t : parsed_values_t