aboutsummaryrefslogtreecommitdiff
path: root/py/objboundmeth.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2015-04-01 14:10:50 +0000
committerDamien George <damien.p.george@gmail.com>2015-04-11 16:54:37 +0100
commitb1bbe966c408901ae64ea8c8b468694c47d05b1a (patch)
tree46025c34daf602aeb1e8def41d1e01f0750b6d13 /py/objboundmeth.c
parentd07ccc5a394d0252ffbc227509ed2134465c215a (diff)
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.
Diffstat (limited to 'py/objboundmeth.c')
-rw-r--r--py/objboundmeth.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/py/objboundmeth.c b/py/objboundmeth.c
index 84d201277..0f9ff08c8 100644
--- a/py/objboundmeth.c
+++ b/py/objboundmeth.c
@@ -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
};