mirror of
https://github.com/micropython/micropython.git
synced 2026-01-06 20:20:14 +01:00
py/parse: Make mp_parse_node_new_leaf an inline function.
It is split into 2 functions, one to make small ints and the other to make a non-small-int leaf node. This reduces code size by 32 bytes on bare-arm, 64 bytes on unix (x64-64) and 144 bytes on stmhal.
This commit is contained in:
@@ -76,7 +76,12 @@ typedef struct _mp_parse_node_struct_t {
|
||||
#define MP_PARSE_NODE_STRUCT_KIND(pns) ((pns)->kind_num_nodes & 0xff)
|
||||
#define MP_PARSE_NODE_STRUCT_NUM_NODES(pns) ((pns)->kind_num_nodes >> 8)
|
||||
|
||||
mp_parse_node_t mp_parse_node_new_leaf(size_t kind, mp_int_t arg);
|
||||
static inline mp_parse_node_t mp_parse_node_new_small_int(mp_int_t val) {
|
||||
return (mp_parse_node_t)(MP_PARSE_NODE_SMALL_INT | ((mp_uint_t)val << 1));
|
||||
}
|
||||
static inline mp_parse_node_t mp_parse_node_new_leaf(size_t kind, mp_int_t arg) {
|
||||
return (mp_parse_node_t)(kind | ((mp_uint_t)arg << 4));
|
||||
}
|
||||
bool mp_parse_node_is_const_false(mp_parse_node_t pn);
|
||||
bool mp_parse_node_is_const_true(mp_parse_node_t pn);
|
||||
bool mp_parse_node_get_int_maybe(mp_parse_node_t pn, mp_obj_t *o);
|
||||
|
||||
Reference in New Issue
Block a user