Mercurial > vim
comparison 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 |
comparison
equal
deleted
inserted
replaced
30424:1a518a4bf1fd | 30425:6c2bbd7d9217 |
---|---|
930 ga_append(&ga, NUL); | 930 ga_append(&ga, NUL); |
931 rettv->vval.v_string = ga.ga_data; | 931 rettv->vval.v_string = ga.ga_data; |
932 } | 932 } |
933 | 933 |
934 /* | 934 /* |
935 * reduce() String argvars[0] using the function 'funcname' with arguments in | 935 * Implementation of reduce() for String "argvars[0]" using the function "expr" |
936 * 'funcexe' starting with the initial value argvars[2] and return the result | 936 * starting with the optional initial value "argvars[2]" and return the result |
937 * in 'rettv'. | 937 * in "rettv". |
938 */ | 938 */ |
939 void | 939 void |
940 string_reduce( | 940 string_reduce( |
941 typval_T *argvars, | 941 typval_T *argvars, |
942 char_u *func_name, | 942 typval_T *expr, |
943 funcexe_T *funcexe, | |
944 typval_T *rettv) | 943 typval_T *rettv) |
945 { | 944 { |
946 char_u *p = tv_get_string(&argvars[0]); | 945 char_u *p = tv_get_string(&argvars[0]); |
947 int len; | 946 int len; |
948 typval_T argv[3]; | 947 typval_T argv[3]; |
969 { | 968 { |
970 argv[0] = *rettv; | 969 argv[0] = *rettv; |
971 if (copy_first_char_to_tv(p, &argv[1]) == FAIL) | 970 if (copy_first_char_to_tv(p, &argv[1]) == FAIL) |
972 break; | 971 break; |
973 len = (int)STRLEN(argv[1].vval.v_string); | 972 len = (int)STRLEN(argv[1].vval.v_string); |
974 r = call_func(func_name, -1, rettv, 2, argv, funcexe); | 973 |
974 r = eval_expr_typval(expr, argv, 2, rettv); | |
975 | |
975 clear_tv(&argv[0]); | 976 clear_tv(&argv[0]); |
976 clear_tv(&argv[1]); | 977 clear_tv(&argv[1]); |
977 if (r == FAIL || called_emsg != called_emsg_start) | 978 if (r == FAIL || called_emsg != called_emsg_start) |
978 return; | 979 return; |
979 } | 980 } |