mirror of
https://github.com/vim/vim.git
synced 2025-09-24 03:44:06 -04:00
patch 8.2.3893: Vim9: many local variables are initialized with an instruction
Problem: Vim9: many local variables are initialized with an instruction. Solution: Initialize local variables to zero to avoid the instructions.
This commit is contained in:
@@ -397,7 +397,12 @@ call_dfunc(
|
||||
|
||||
// Initialize local variables
|
||||
for (idx = 0; idx < dfunc->df_varcount; ++idx)
|
||||
STACK_TV_BOT(STACK_FRAME_SIZE + idx)->v_type = VAR_UNKNOWN;
|
||||
{
|
||||
typval_T *tv = STACK_TV_BOT(STACK_FRAME_SIZE + idx);
|
||||
|
||||
tv->v_type = VAR_NUMBER;
|
||||
tv->vval.v_number = 0;
|
||||
}
|
||||
if (dfunc->df_has_closure)
|
||||
{
|
||||
typval_T *tv = STACK_TV_BOT(STACK_FRAME_SIZE + dfunc->df_varcount);
|
||||
@@ -5002,8 +5007,13 @@ call_def_function(
|
||||
dfunc_T *dfunc = ((dfunc_T *)def_functions.ga_data)
|
||||
+ ufunc->uf_dfunc_idx;
|
||||
|
||||
// Initialize variables to zero. That avoids having to generate
|
||||
// initializing instructions for "var nr: number", "var x: any", etc.
|
||||
for (idx = 0; idx < dfunc->df_varcount; ++idx)
|
||||
STACK_TV_VAR(idx)->v_type = VAR_UNKNOWN;
|
||||
{
|
||||
STACK_TV_VAR(idx)->v_type = VAR_NUMBER;
|
||||
STACK_TV_VAR(idx)->vval.v_number = 0;
|
||||
}
|
||||
ectx.ec_stack.ga_len += dfunc->df_varcount;
|
||||
if (dfunc->df_has_closure)
|
||||
{
|
||||
|
Reference in New Issue
Block a user