summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2022-09-28 15:19:10 +0100
committerBram Moolenaar <Bram@vim.org>2022-09-28 15:19:10 +0100
commit1936c765364d6a771cea5df9971318060db82730 (patch)
tree1f4aece4224291febd9b62aca283ddcf8c5c6e65
parent371951d0c34d4f44b50ad8bc8d30a4ef7effade6 (diff)
patch 9.0.0617: calling function for reduce() has too much overheadv9.0.0617
Problem: Calling function for reduce() has too much overhead. Solution: Only call clear_tv() when needed.
-rw-r--r--src/list.c4
-rw-r--r--src/version.c2
-rw-r--r--src/vim9execute.c13
3 files changed, 14 insertions, 5 deletions
diff --git a/src/list.c b/src/list.c
index fab86fd752..a39c9f974b 100644
--- a/src/list.c
+++ b/src/list.c
@@ -3073,10 +3073,12 @@ list_reduce(
r = eval_expr_typval(expr, argv, 2, rettv);
- clear_tv(&argv[0]);
+ if (argv[0].v_type != VAR_NUMBER && argv[0].v_type != VAR_UNKNOWN)
+ clear_tv(&argv[0]);
if (r == FAIL || called_emsg != called_emsg_start)
break;
+ // advance to the next item
if (range_list)
{
range_val += l->lv_u.nonmat.lv_stride;
diff --git a/src/version.c b/src/version.c
index 815f27b8db..43569d01c4 100644
--- a/src/version.c
+++ b/src/version.c
@@ -700,6 +700,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 617,
+/**/
616,
/**/
615,
diff --git a/src/vim9execute.c b/src/vim9execute.c
index 1699caf496..ddcbe2c76b 100644
--- a/src/vim9execute.c
+++ b/src/vim9execute.c
@@ -710,7 +710,8 @@ handle_closure_in_use(ectx_T *ectx, int free_arguments)
return FAIL;
funcstack->fs_var_offset = argcount + STACK_FRAME_SIZE;
- funcstack->fs_ga.ga_len = funcstack->fs_var_offset + dfunc->df_varcount;
+ funcstack->fs_ga.ga_len = funcstack->fs_var_offset
+ + dfunc->df_varcount;
stack = ALLOC_CLEAR_MULT(typval_T, funcstack->fs_ga.ga_len);
funcstack->fs_ga.ga_data = stack;
if (stack == NULL)
@@ -5881,7 +5882,11 @@ call_def_function(
failed_early:
// Free all arguments and local variables.
for (idx = 0; idx < ectx.ec_stack.ga_len; ++idx)
- clear_tv(STACK_TV(idx));
+ {
+ tv = STACK_TV(idx);
+ if (tv->v_type != VAR_NUMBER && tv->v_type != VAR_UNKNOWN)
+ clear_tv(tv);
+ }
ex_nesting_level = orig_nesting_level;
vim_free(ectx.ec_stack.ga_data);
@@ -6371,11 +6376,11 @@ list_instructions(char *pfx, isn_T *instr, int instr_count, ufunc_T *ufunc)
break;
case ISN_NEWLIST:
smsg("%s%4d NEWLIST size %lld", pfx, current,
- (varnumber_T)(iptr->isn_arg.number));
+ (varnumber_T)(iptr->isn_arg.number));
break;
case ISN_NEWDICT:
smsg("%s%4d NEWDICT size %lld", pfx, current,
- (varnumber_T)(iptr->isn_arg.number));
+ (varnumber_T)(iptr->isn_arg.number));
break;
case ISN_NEWPARTIAL:
smsg("%s%4d NEWPARTIAL", pfx, current);