From e97df976008ea8d3dbd291ebcc72f5416d63a7ce Mon Sep 17 00:00:00 2001 From: Damien George Date: Fri, 23 Sep 2016 12:13:51 +1000 Subject: [PATCH] py: Shrink mp_arg_t struct by using reduced-size integer members. qstrs ids are restricted to fit within 2 bytes already (eg in persistent bytecode) so it's safe to use a uint16_t to store them in mp_arg_t. And the flags member only needs a maximum of 2 bytes so can also use uint16_t. Savings in code size can be significant when many mp_arg_t structs are used for argument parsing. Eg, this patch reduces stmhal by 480 bytes. --- py/runtime.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/py/runtime.h b/py/runtime.h index 06e68924b2..29b38853f6 100644 --- a/py/runtime.h +++ b/py/runtime.h @@ -52,8 +52,8 @@ typedef union _mp_arg_val_t { } mp_arg_val_t; typedef struct _mp_arg_t { - qstr qst; - mp_uint_t flags; + uint16_t qst; + uint16_t flags; mp_arg_val_t defval; } mp_arg_t;