mirror of
https://github.com/vim/vim.git
synced 2025-09-30 04:44:14 -04:00
patch 8.2.0056: execution stack is incomplete and inefficient
Problem: Execution stack is incomplete and inefficient. Solution: Introduce a proper execution stack and use it instead of sourcing_name/sourcing_lnum. Create a string only when used.
This commit is contained in:
20
src/main.c
20
src/main.c
@@ -911,6 +911,7 @@ vim_main2(void)
|
||||
void
|
||||
common_init(mparm_T *paramp)
|
||||
{
|
||||
estack_init();
|
||||
cmdline_init();
|
||||
|
||||
(void)mb_init(); // init mb_bytelen_tab[] to ones
|
||||
@@ -3089,13 +3090,13 @@ exe_pre_commands(mparm_T *parmp)
|
||||
if (cnt > 0)
|
||||
{
|
||||
curwin->w_cursor.lnum = 0; // just in case..
|
||||
sourcing_name = (char_u *)_("pre-vimrc command line");
|
||||
estack_push(ETYPE_ARGS, (char_u *)_("pre-vimrc command line"), 0);
|
||||
# ifdef FEAT_EVAL
|
||||
current_sctx.sc_sid = SID_CMDARG;
|
||||
# endif
|
||||
for (i = 0; i < cnt; ++i)
|
||||
do_cmdline_cmd(cmds[i]);
|
||||
sourcing_name = NULL;
|
||||
estack_pop();
|
||||
# ifdef FEAT_EVAL
|
||||
current_sctx.sc_sid = 0;
|
||||
# endif
|
||||
@@ -3119,7 +3120,7 @@ exe_commands(mparm_T *parmp)
|
||||
msg_scroll = TRUE;
|
||||
if (parmp->tagname == NULL && curwin->w_cursor.lnum <= 1)
|
||||
curwin->w_cursor.lnum = 0;
|
||||
sourcing_name = (char_u *)"command line";
|
||||
estack_push(ETYPE_ARGS, (char_u *)"command line", 0);
|
||||
#ifdef FEAT_EVAL
|
||||
current_sctx.sc_sid = SID_CARG;
|
||||
current_sctx.sc_seq = 0;
|
||||
@@ -3130,7 +3131,7 @@ exe_commands(mparm_T *parmp)
|
||||
if (parmp->cmds_tofree[i])
|
||||
vim_free(parmp->commands[i]);
|
||||
}
|
||||
sourcing_name = NULL;
|
||||
estack_pop();
|
||||
#ifdef FEAT_EVAL
|
||||
current_sctx.sc_sid = 0;
|
||||
#endif
|
||||
@@ -3336,8 +3337,6 @@ process_env(
|
||||
int is_viminit) // when TRUE, called for VIMINIT
|
||||
{
|
||||
char_u *initstr;
|
||||
char_u *save_sourcing_name;
|
||||
linenr_T save_sourcing_lnum;
|
||||
#ifdef FEAT_EVAL
|
||||
sctx_T save_current_sctx;
|
||||
#endif
|
||||
@@ -3346,10 +3345,7 @@ process_env(
|
||||
{
|
||||
if (is_viminit)
|
||||
vimrc_found(NULL, NULL);
|
||||
save_sourcing_name = sourcing_name;
|
||||
save_sourcing_lnum = sourcing_lnum;
|
||||
sourcing_name = env;
|
||||
sourcing_lnum = 0;
|
||||
estack_push(ETYPE_ENV, env, 0);
|
||||
#ifdef FEAT_EVAL
|
||||
save_current_sctx = current_sctx;
|
||||
current_sctx.sc_sid = SID_ENV;
|
||||
@@ -3358,8 +3354,8 @@ process_env(
|
||||
current_sctx.sc_version = 1;
|
||||
#endif
|
||||
do_cmdline_cmd(initstr);
|
||||
sourcing_name = save_sourcing_name;
|
||||
sourcing_lnum = save_sourcing_lnum;
|
||||
|
||||
estack_pop();
|
||||
#ifdef FEAT_EVAL
|
||||
current_sctx = save_current_sctx;
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user