Skip to content

Commit e97df97

Browse files
committed
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.
1 parent 46ab042 commit e97df97

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

py/runtime.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ typedef union _mp_arg_val_t {
5252
} mp_arg_val_t;
5353

5454
typedef struct _mp_arg_t {
55-
qstr qst;
56-
mp_uint_t flags;
55+
uint16_t qst;
56+
uint16_t flags;
5757
mp_arg_val_t defval;
5858
} mp_arg_t;
5959

0 commit comments

Comments
 (0)