mirror of
https://github.com/micropython/micropython.git
synced 2025-09-03 08:20:28 +02:00
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
This commit is contained in:
@@ -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
|
||||
|
Reference in New Issue
Block a user