summaryrefslogtreecommitdiff
path: root/src/dict.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2022-09-28 16:16:15 +0100
committerBram Moolenaar <Bram@vim.org>2022-09-28 16:16:15 +0100
commit82418263fa91792e851cb0de879d1595327d5531 (patch)
treee14f38d9dba9dce01e0c3b6c6612ca577bf27b49 /src/dict.c
parent1936c765364d6a771cea5df9971318060db82730 (diff)
downloadvim-git-82418263fa91792e851cb0de879d1595327d5531.tar.gz
patch 9.0.0618: calling function for reduce() has too much overheadv9.0.0618
Problem: Calling function for reduce() has too much overhead. Solution: Do not create a funccall_T every time.
Diffstat (limited to 'src/dict.c')
-rw-r--r--src/dict.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/dict.c b/src/dict.c
index 1cb3e89a8..63b30e06b 100644
--- a/src/dict.c
+++ b/src/dict.c
@@ -1315,6 +1315,8 @@ dict_filter_map(
dictitem_T *di;
int todo;
int rem;
+ typval_T newtv;
+ funccall_T *fc;
if (filtermap == FILTERMAP_MAPNEW)
{
@@ -1335,6 +1337,9 @@ dict_filter_map(
d_ret = rettv->vval.v_dict;
}
+ // Create one funccal_T for all eval_expr_typval() calls.
+ fc = eval_expr_get_funccal(expr, &newtv);
+
if (filtermap != FILTERMAP_FILTER && d->dv_lock == 0)
d->dv_lock = VAR_LOCKED;
ht = &d->dv_hashtab;
@@ -1345,7 +1350,6 @@ dict_filter_map(
if (!HASHITEM_EMPTY(hi))
{
int r;
- typval_T newtv;
--todo;
di = HI2DI(hi);
@@ -1357,8 +1361,7 @@ dict_filter_map(
break;
set_vim_var_string(VV_KEY, di->di_key, -1);
newtv.v_type = VAR_UNKNOWN;
- r = filter_map_one(&di->di_tv, expr, filtermap,
- &newtv, &rem);
+ r = filter_map_one(&di->di_tv, expr, filtermap, fc, &newtv, &rem);
clear_tv(get_vim_var_tv(VV_KEY));
if (r == FAIL || did_emsg)
{
@@ -1398,6 +1401,8 @@ dict_filter_map(
}
hash_unlock(ht);
d->dv_lock = prev_lock;
+ if (fc != NULL)
+ remove_funccal();
}
/*