summaryrefslogtreecommitdiffstatshomepage
path: root/py/objfun.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2018-09-14 13:39:17 +1000
committerDamien George <damien.p.george@gmail.com>2018-09-14 13:39:17 +1000
commit9f241ef398cb0a7fbccc93b36a0fe032f89221e4 (patch)
tree2cad97a08e3860ca9dff1ff7ae3718a2f6bce616 /py/objfun.c
parent0f4d595bebb82cfdd6264e1d18455faa0502ff31 (diff)
downloadmicropython-9f241ef398cb0a7fbccc93b36a0fe032f89221e4.tar.gz
micropython-9f241ef398cb0a7fbccc93b36a0fe032f89221e4.zip
py: Optimise call to mp_arg_check_num by compressing fun signature.
With 5 arguments to mp_arg_check_num(), some architectures need to pass values on the stack. So compressing n_args_min, n_args_max, takes_kw into a single word and passing only 3 arguments makes the call more efficient, because almost all calls to this function pass in constant values. Code size is also reduced by a decent amount: bare-arm: -116 minimal x86: -64 unix x64: -256 unix nanbox: -112 stm32: -324 cc3200: -192 esp8266: -192 esp32: -144
Diffstat (limited to 'py/objfun.c')
-rw-r--r--py/objfun.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/py/objfun.c b/py/objfun.c
index df377441e0..e7f2b79ada 100644
--- a/py/objfun.c
+++ b/py/objfun.c
@@ -110,9 +110,9 @@ STATIC mp_obj_t fun_builtin_var_call(mp_obj_t self_in, size_t n_args, size_t n_k
mp_obj_fun_builtin_var_t *self = MP_OBJ_TO_PTR(self_in);
// check number of arguments
- mp_arg_check_num(n_args, n_kw, self->n_args_min, self->n_args_max, self->is_kw);
+ mp_arg_check_num_sig(n_args, n_kw, self->sig);
- if (self->is_kw) {
+ if (self->sig & 1) {
// function allows keywords
// we create a map directly from the given args array