py: Combine load_attr and store_attr type methods into one (attr).
This simplifies the API for objects and reduces code size (by around 400 bytes on Thumb2, and around 2k on x86). Performance impact was measured with Pystone score, but change was barely noticeable.
This commit is contained in:
@@ -71,7 +71,11 @@ STATIC mp_obj_t bound_meth_call(mp_obj_t self_in, mp_uint_t n_args, mp_uint_t n_
|
||||
}
|
||||
|
||||
#if MICROPY_PY_FUNCTION_ATTRS
|
||||
STATIC void bound_meth_load_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
|
||||
STATIC void bound_meth_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
|
||||
if (dest[0] != MP_OBJ_NULL) {
|
||||
// not load attribute
|
||||
return;
|
||||
}
|
||||
if (attr == MP_QSTR___name__) {
|
||||
mp_obj_bound_meth_t *o = self_in;
|
||||
dest[0] = MP_OBJ_NEW_QSTR(mp_obj_fun_get_name(o->meth));
|
||||
@@ -87,7 +91,7 @@ STATIC const mp_obj_type_t mp_type_bound_meth = {
|
||||
#endif
|
||||
.call = bound_meth_call,
|
||||
#if MICROPY_PY_FUNCTION_ATTRS
|
||||
.load_attr = bound_meth_load_attr,
|
||||
.attr = bound_meth_attr,
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user