diff options
author | Bram Moolenaar <Bram@vim.org> | 2022-09-28 16:16:15 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2022-09-28 16:16:15 +0100 |
commit | 82418263fa91792e851cb0de879d1595327d5531 (patch) | |
tree | e14f38d9dba9dce01e0c3b6c6612ca577bf27b49 /src/blob.c | |
parent | 1936c765364d6a771cea5df9971318060db82730 (diff) | |
download | vim-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/blob.c')
-rw-r--r-- | src/blob.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/blob.c b/src/blob.c index e4d23d260..a4e99818c 100644 --- a/src/blob.c +++ b/src/blob.c @@ -559,6 +559,8 @@ blob_filter_map( blob_T *b_ret; int idx = 0; int rem; + typval_T newtv; + funccall_T *fc; if (filtermap == FILTERMAP_MAPNEW) { @@ -579,15 +581,16 @@ blob_filter_map( // set_vim_var_nr() doesn't set the type set_vim_var_type(VV_KEY, VAR_NUMBER); + // Create one funccal_T for all eval_expr_typval() calls. + fc = eval_expr_get_funccal(expr, &newtv); + for (i = 0; i < b->bv_ga.ga_len; i++) { - typval_T newtv; - tv.v_type = VAR_NUMBER; val = blob_get(b, i); tv.vval.v_number = val; set_vim_var_nr(VV_KEY, idx); - if (filter_map_one(&tv, expr, filtermap, &newtv, &rem) == FAIL + if (filter_map_one(&tv, expr, filtermap, fc, &newtv, &rem) == FAIL || did_emsg) break; if (newtv.v_type != VAR_NUMBER && newtv.v_type != VAR_BOOL) @@ -612,6 +615,9 @@ blob_filter_map( } ++idx; } + + if (fc != NULL) + remove_funccal(); } /* @@ -714,7 +720,7 @@ blob_reduce( argv[1].v_type = VAR_NUMBER; argv[1].vval.v_number = blob_get(b, i); - r = eval_expr_typval(expr, argv, 2, rettv); + r = eval_expr_typval(expr, argv, 2, NULL, rettv); clear_tv(&argv[0]); if (r == FAIL || called_emsg != called_emsg_start) |