summaryrefslogtreecommitdiff
path: root/py
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2017-10-04 11:31:05 +1100
committerDamien George <damien.p.george@gmail.com>2017-10-04 11:31:05 +1100
commit6c82cfc089466f0b3f4b61c81baee1cabece1eaa (patch)
tree66bc2b41f1a6bcdb5c0e3b20c1f6c908edd32e69 /py
parent9e0cdb22f1a549d5e542418a3007c756cd594b84 (diff)
py/objtype: Change type of enum-to-qstr table to uint16_t to save space.
Qstr values fit in 16-bits (and this fact is used elsewhere in the code) so no need to use more than that for the large lookup tables. The compiler will anyway give a warning if the qstr values don't fit in 16 bits. Saves around 80 bytes of code space for Thumb2 archs.
Diffstat (limited to 'py')
-rw-r--r--py/objtype.c4
-rw-r--r--py/runtime.h6
2 files changed, 5 insertions, 5 deletions
diff --git a/py/objtype.c b/py/objtype.c
index cf9311d5c..033765a47 100644
--- a/py/objtype.c
+++ b/py/objtype.c
@@ -334,7 +334,7 @@ mp_obj_t mp_obj_instance_make_new(const mp_obj_type_t *self, size_t n_args, size
return MP_OBJ_FROM_PTR(o);
}
-const qstr mp_unary_op_method_name[] = {
+const uint16_t mp_unary_op_method_name[] = {
[MP_UNARY_OP_BOOL] = MP_QSTR___bool__,
[MP_UNARY_OP_LEN] = MP_QSTR___len__,
[MP_UNARY_OP_HASH] = MP_QSTR___hash__,
@@ -408,7 +408,7 @@ STATIC mp_obj_t instance_unary_op(mp_unary_op_t op, mp_obj_t self_in) {
}
}
-const qstr mp_binary_op_method_name[] = {
+const uint16_t mp_binary_op_method_name[] = {
/*
MP_BINARY_OP_OR,
MP_BINARY_OP_XOR,
diff --git a/py/runtime.h b/py/runtime.h
index bbdd7647e..da12f8f04 100644
--- a/py/runtime.h
+++ b/py/runtime.h
@@ -57,9 +57,9 @@ typedef struct _mp_arg_t {
mp_arg_val_t defval;
} mp_arg_t;
-// defined in objtype.c
-extern const qstr mp_unary_op_method_name[];
-extern const qstr mp_binary_op_method_name[];
+// Tables mapping operator enums to qstrs, defined in objtype.c
+extern const uint16_t mp_unary_op_method_name[];
+extern const uint16_t mp_binary_op_method_name[];
void mp_init(void);
void mp_deinit(void);