Mercurial > vim
diff src/strings.c @ 30425:6c2bbd7d9217 v9.0.0548
patch 9.0.0548: reduce() with a compiled lambda could be faster
Commit: https://github.com/vim/vim/commit/f1c60d4bf10794265b828afd9c5f7eddacada10b
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Sep 22 17:07:00 2022 +0100
patch 9.0.0548: reduce() with a compiled lambda could be faster
Problem: reduce() with a compiled lambda could be faster.
Solution: Call eval_expr_typval() instead of call_func() directly.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 22 Sep 2022 18:15:03 +0200 |
parents | 029c59bf78f1 |
children | b3de17181c19 |
line wrap: on
line diff
--- 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)