From 18a206abd2b2b75f2df0014005e5f568412fb836 Mon Sep 17 00:00:00 2001 From: Dianne Skoll Date: Sat, 1 Jun 2024 09:30:42 -0400 Subject: [PATCH] Store args on stack if possible. --- src/expr.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/expr.c b/src/expr.c index 4ff3bd63..5b9fc4ea 100644 --- a/src/expr.c +++ b/src/expr.c @@ -195,6 +195,7 @@ eval_builtin(expr_node *node, Value *locals, Value *ans, int *nonconst) BuiltinFunc *f = node->u.builtin_func; expr_node *kid; int i, j, r; + Value stack_args[10]; /* Check that we have the right number of argumens */ if (node->num_kids < f->minargs) return E_2FEW_ARGS; @@ -207,9 +208,13 @@ eval_builtin(expr_node *node, Value *locals, Value *ans, int *nonconst) info.nargs = node->num_kids; if (info.nargs) { - info.args = malloc(info.nargs * sizeof(Value)); - if (!info.args) { - return E_NO_MEM; + if (info.nargs <= 10) { + info.args = stack_args; + } else { + info.args = malloc(info.nargs * sizeof(Value)); + if (!info.args) { + return E_NO_MEM; + } } } else { info.args = NULL; @@ -223,7 +228,9 @@ eval_builtin(expr_node *node, Value *locals, Value *ans, int *nonconst) for (j=0; jtype == N_SHORT_USER_FUNC) {