diff options
| author | Damien George | 2014-02-01 18:29:40 +0000 |
|---|---|---|
| committer | Damien George | 2014-02-01 18:29:40 +0000 |
| commit | fb083ea986d758c7426fda091c4899f0511aaa8c (patch) | |
| tree | f63392368dc5140441ab3f0d8a04ec1ca9585871 /py/objfun.c | |
| parent | 87413a4d0c579ec491cf52ab8d6520430df64c7d (diff) | |
py: mp_execute_byte_code has 2 arg arrays, for more efficient default params.
Diffstat (limited to 'py/objfun.c')
| -rw-r--r-- | py/objfun.c | 25 |
1 files changed, 6 insertions, 19 deletions
diff --git a/py/objfun.c b/py/objfun.c index c60800bfc..fbc0cab11 100644 --- a/py/objfun.c +++ b/py/objfun.c @@ -154,26 +154,13 @@ mp_obj_t fun_bc_call(mp_obj_t self_in, uint n_args, uint n_kw, const mp_obj_t *a nlr_jump(mp_obj_new_exception_msg(MP_QSTR_TypeError, "function does not take keyword arguments")); } - mp_obj_t full_args[n_args]; - if (n_args < self->n_args) { - memcpy(full_args, args, n_args * sizeof(*args)); - int use_def_args = self->n_args - n_args; - memcpy(full_args + n_args, self->def_args + self->n_def_args - use_def_args, use_def_args * sizeof(*args)); - args = full_args; - n_args = self->n_args; - } - - // optimisation: allow the compiler to optimise this tail call for - // the common case when the globals don't need to be changed + uint use_def_args = self->n_args - n_args; mp_map_t *old_globals = rt_globals_get(); - if (self->globals == old_globals) { - return mp_execute_byte_code(self->bytecode, args, n_args, self->n_state); - } else { - rt_globals_set(self->globals); - mp_obj_t result = mp_execute_byte_code(self->bytecode, args, n_args, self->n_state); - rt_globals_set(old_globals); - return result; - } + rt_globals_set(self->globals); + mp_obj_t result = mp_execute_byte_code(self->bytecode, args, n_args, self->def_args + self->n_def_args - use_def_args, use_def_args, self->n_state); + rt_globals_set(old_globals); + + return result; } const mp_obj_type_t fun_bc_type = { |
