Skip to content

Commit c71edae

Browse files
committed
py/objfun: Remove unnecessary check for viper fun with 5 or more args.
The native emitter/compiler restricts viper functions to 4 args, so there is no need for an extra check in the dynamic dispatch.
1 parent 88ca7ff commit c71edae

1 file changed

Lines changed: 3 additions & 5 deletions

File tree

py/objfun.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -409,17 +409,15 @@ STATIC mp_obj_t fun_viper_call(mp_obj_t self_in, size_t n_args, size_t n_kw, con
409409
ret = ((viper_fun_2_t)fun)(mp_convert_obj_to_native(args[0], self->type_sig >> 4), mp_convert_obj_to_native(args[1], self->type_sig >> 8));
410410
} else if (n_args == 3) {
411411
ret = ((viper_fun_3_t)fun)(mp_convert_obj_to_native(args[0], self->type_sig >> 4), mp_convert_obj_to_native(args[1], self->type_sig >> 8), mp_convert_obj_to_native(args[2], self->type_sig >> 12));
412-
} else if (n_args == 4) {
412+
} else {
413+
// compiler allows at most 4 arguments
414+
assert(n_args == 4);
413415
ret = ((viper_fun_4_t)fun)(
414416
mp_convert_obj_to_native(args[0], self->type_sig >> 4),
415417
mp_convert_obj_to_native(args[1], self->type_sig >> 8),
416418
mp_convert_obj_to_native(args[2], self->type_sig >> 12),
417419
mp_convert_obj_to_native(args[3], self->type_sig >> 16)
418420
);
419-
} else {
420-
// TODO 5 or more arguments not supported for viper call
421-
assert(0);
422-
ret = 0;
423421
}
424422

425423
return mp_convert_native_to_obj(ret, self->type_sig);

0 commit comments

Comments
 (0)