summaryrefslogtreecommitdiff
path: root/src/strings.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2022-09-22 17:07:00 +0100
committerBram Moolenaar <Bram@vim.org>2022-09-22 17:07:00 +0100
commitf1c60d4bf10794265b828afd9c5f7eddacada10b (patch)
tree97da67230b5a297698ea6065aca3adb0912ab751 /src/strings.c
parent6d313bec535d9ccc24f6f82025280a61caad7416 (diff)
downloadvim-git-f1c60d4bf10794265b828afd9c5f7eddacada10b.tar.gz
patch 9.0.0548: reduce() with a compiled lambda could be fasterv9.0.0548
Problem: reduce() with a compiled lambda could be faster. Solution: Call eval_expr_typval() instead of call_func() directly.
Diffstat (limited to 'src/strings.c')
-rw-r--r--src/strings.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/strings.c b/src/strings.c
index 3befb86ea..15ead2bfb 100644
--- a/src/strings.c
+++ b/src/strings.c
@@ -932,15 +932,14 @@ string_filter_map(
}
/*
- * reduce() String argvars[0] using the function 'funcname' with arguments in
- * 'funcexe' starting with the initial value argvars[2] and return the result
- * in 'rettv'.
+ * Implementation of reduce() for String "argvars[0]" using the function "expr"
+ * starting with the optional initial value "argvars[2]" and return the result
+ * in "rettv".
*/
void
string_reduce(
typval_T *argvars,
- char_u *func_name,
- funcexe_T *funcexe,
+ typval_T *expr,
typval_T *rettv)
{
char_u *p = tv_get_string(&argvars[0]);
@@ -971,7 +970,9 @@ string_reduce(
if (copy_first_char_to_tv(p, &argv[1]) == FAIL)
break;
len = (int)STRLEN(argv[1].vval.v_string);
- r = call_func(func_name, -1, rettv, 2, argv, funcexe);
+
+ r = eval_expr_typval(expr, argv, 2, rettv);
+
clear_tv(&argv[0]);
clear_tv(&argv[1]);
if (r == FAIL || called_emsg != called_emsg_start)