summaryrefslogtreecommitdiffstatshomepage
path: root/py/objtype.h
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/objtype.h
parent94beeabd2ee179d587942046555833e022241f24 (diff)
downloadmicropython-b41aaaa8a918a6645ebc6bfa4483bd17286f9263.tar.gz
micropython-b41aaaa8a918a6645ebc6bfa4483bd17286f9263.zip
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/objtype.h')
-rw-r--r--py/objtype.h6
1 files changed, 2 insertions, 4 deletions
diff --git a/py/objtype.h b/py/objtype.h
index 76a290760c..839cc6d146 100644
--- a/py/objtype.h
+++ b/py/objtype.h
@@ -46,10 +46,8 @@ mp_obj_instance_t *mp_obj_new_instance(const mp_obj_type_t *cls, const mp_obj_ty
bool mp_obj_instance_is_callable(mp_obj_t self_in);
mp_obj_t mp_obj_instance_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args);
-#define mp_obj_is_instance_type(type) (MP_OBJ_TYPE_GET_SLOT_OR_NULL(type, make_new) == mp_obj_instance_make_new)
-#define mp_obj_is_native_type(type) (MP_OBJ_TYPE_GET_SLOT_OR_NULL(type, make_new) != mp_obj_instance_make_new)
-// this needs to be exposed for the above macros to work correctly
-mp_obj_t mp_obj_instance_make_new(const mp_obj_type_t *self_in, size_t n_args, size_t n_kw, const mp_obj_t *args);
+#define mp_obj_is_instance_type(type) ((type)->flags & MP_TYPE_FLAG_INSTANCE_TYPE)
+#define mp_obj_is_native_type(type) (!((type)->flags & MP_TYPE_FLAG_INSTANCE_TYPE))
// this needs to be exposed for mp_getiter
mp_obj_t mp_obj_instance_getiter(mp_obj_t self_in, mp_obj_iter_buf_t *iter_buf);