From ea0fa417084012b1c44d3325e8fa0dbd47106952 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Wed, 18 Apr 2018 06:55:31 -0700 Subject: apply: eliminate wasteful consing. Now (pprof (apply '+ 1 2 3 4 5 '(6 7))) shows zero bytes consed. Previously 176 (on 32 bit). This is the same whether the expression is compiled or interpreted. * eval.c (applyv): Rewritten to efficiently manipulate the args and call generic_funcall directly. The consing funcction apply_intrinsic_frob_args is only used when args contains a trailing list (args->list) and is only used on that trailing list, not the entire arg list. Also, changing the static function to external. * eval.h (applyv): Declared. * vm.c (vm_apply): Use applyv instead of wastefully converting the arguments to a consed list and going through apply_intrinsic. --- eval.h | 1 + 1 file changed, 1 insertion(+) (limited to 'eval.h') diff --git a/eval.h b/eval.h index fa0dc88a..4122d174 100644 --- a/eval.h +++ b/eval.h @@ -67,6 +67,7 @@ void reg_mac(val sym, val fun); val set_get_symacro(val sym, val form); val apply(val fun, val arglist); val apply_intrinsic(val fun, val args); +val applyv(val fun, struct args *args); val eval_progn(val forms, val env, val ctx_form); val eval(val form, val env, val ctx_form); val eval_intrinsic(val form, val env); -- cgit v1.2.3