diff options
author | Jim Mussared <jim.mussared@gmail.com> | 2022-09-17 22:22:32 +1000 |
---|---|---|
committer | Damien George <damien@micropython.org> | 2022-09-19 19:06:16 +1000 |
commit | b41aaaa8a918a6645ebc6bfa4483bd17286f9263 (patch) | |
tree | 717c8d785154277b21bd10b0fd9e4fc54af61912 /py/objexcept.c | |
parent | 94beeabd2ee179d587942046555833e022241f24 (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/objexcept.c')
-rw-r--r-- | py/objexcept.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/py/objexcept.c b/py/objexcept.c index 3b76ae62c..515cbe742 100644 --- a/py/objexcept.c +++ b/py/objexcept.c @@ -111,6 +111,10 @@ mp_obj_t mp_alloc_emergency_exception_buf(mp_obj_t size_in) { #endif #endif // MICROPY_ENABLE_EMERGENCY_EXCEPTION_BUF +bool mp_obj_is_native_exception_instance(mp_obj_t self_in) { + return MP_OBJ_TYPE_GET_SLOT_OR_NULL(mp_obj_get_type(self_in), make_new) == mp_obj_exception_make_new; +} + STATIC mp_obj_exception_t *get_native_exception(mp_obj_t self_in) { assert(mp_obj_is_exception_instance(self_in)); if (mp_obj_is_native_exception_instance(self_in)) { |