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. --- vm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'vm.c') diff --git a/vm.c b/vm.c index 362f1adb..c0370343 100644 --- a/vm.c +++ b/vm.c @@ -464,7 +464,7 @@ static void vm_apply(struct vm *vm, vm_word_t insn) } } - result = apply_intrinsic(vm_get(vm->dspl, fun), args_get_list(args)); + result = applyv(vm_get(vm->dspl, fun), args); vm_set(vm->dspl, dest, result); } -- cgit v1.2.3