diff options
author | Damien George <damien.p.george@gmail.com> | 2015-04-01 14:10:50 +0000 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2015-04-11 16:54:37 +0100 |
commit | b1bbe966c408901ae64ea8c8b468694c47d05b1a (patch) | |
tree | 46025c34daf602aeb1e8def41d1e01f0750b6d13 /py/objfun.c | |
parent | d07ccc5a394d0252ffbc227509ed2134465c215a (diff) | |
download | micropython-b1bbe966c408901ae64ea8c8b468694c47d05b1a.tar.gz micropython-b1bbe966c408901ae64ea8c8b468694c47d05b1a.zip |
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/objfun.c')
-rw-r--r-- | py/objfun.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/py/objfun.c b/py/objfun.c index 76adfef500..f00a90a089 100644 --- a/py/objfun.c +++ b/py/objfun.c @@ -296,7 +296,11 @@ STATIC mp_obj_t fun_bc_call(mp_obj_t self_in, mp_uint_t n_args, mp_uint_t n_kw, } #if MICROPY_PY_FUNCTION_ATTRS -STATIC void fun_bc_load_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) { +STATIC void fun_bc_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__) { dest[0] = MP_OBJ_NEW_QSTR(mp_obj_fun_get_name(self_in)); } @@ -311,7 +315,7 @@ const mp_obj_type_t mp_type_fun_bc = { #endif .call = fun_bc_call, #if MICROPY_PY_FUNCTION_ATTRS - .load_attr = fun_bc_load_attr, + .attr = fun_bc_attr, #endif }; |