summaryrefslogtreecommitdiff
path: root/py/objdict.c
diff options
context:
space:
mode:
authorJim Mussared <jim.mussared@gmail.com>2022-09-17 22:22:32 +1000
committerDamien George <damien@micropython.org>2022-09-19 19:06:16 +1000
commitb41aaaa8a918a6645ebc6bfa4483bd17286f9263 (patch)
tree717c8d785154277b21bd10b0fd9e4fc54af61912 /py/objdict.c
parent94beeabd2ee179d587942046555833e022241f24 (diff)
py/obj: Optimise code size and performance for make_new as a slot.
The check for make_new (i.e. used to determine something's type) is now more complicated due to the slot access. This commit changes the inlining of a few frequently-used helpers to overall improve code size and performance.
Diffstat (limited to 'py/objdict.c')
-rw-r--r--py/objdict.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/py/objdict.c b/py/objdict.c
index 68c33961c..7fad5fc8f 100644
--- a/py/objdict.c
+++ b/py/objdict.c
@@ -33,6 +33,10 @@
#include "py/objtype.h"
#include "py/objstr.h"
+bool mp_obj_is_dict_or_ordereddict(mp_obj_t o) {
+ return mp_obj_is_obj(o) && MP_OBJ_TYPE_GET_SLOT_OR_NULL(((mp_obj_base_t *)MP_OBJ_TO_PTR(o))->type, make_new) == mp_obj_dict_make_new;
+}
+
const mp_obj_dict_t mp_const_empty_dict_obj = {
.base = { .type = &mp_type_dict },
.map = {