diff options
author | Bram Moolenaar <Bram@vim.org> | 2022-01-11 12:37:20 +0000 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2022-01-11 12:37:20 +0000 |
commit | d6f27c66cca32b93fcf8024b1bad1618946bbbea (patch) | |
tree | 6744abbc86e5f33619c467cfbfe93c8380043cf2 /src/evalwindow.c | |
parent | 19db9e6ba710ca32f0f5e0c2ca2ba69f8228b833 (diff) |
patch 8.2.4060: win_execute() slow on systems where getcwd()/chdir() is slowv8.2.4060
Problem: win_execute() is slow on systems where getcwd() or chdir() is
slow. (Rick Howe)
Solution: Avoid using getcwd() and chdir() if no local directory is used and
'acd' is not set. (closes #9504)
Diffstat (limited to 'src/evalwindow.c')
-rw-r--r-- | src/evalwindow.c | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/src/evalwindow.c b/src/evalwindow.c index f2d9a0b444..a47a0c0470 100644 --- a/src/evalwindow.c +++ b/src/evalwindow.c @@ -707,13 +707,26 @@ f_win_execute(typval_T *argvars, typval_T *rettv) { pos_T curpos = wp->w_cursor; char_u cwd[MAXPATHL]; - int cwd_status; + int cwd_status = FAIL; #ifdef FEAT_AUTOCHDIR char_u autocwd[MAXPATHL]; int apply_acd = FALSE; #endif - cwd_status = mch_dirname(cwd, MAXPATHL); + // Getting and setting directory can be slow on some systems, only do + // this when the current or target window/tab have a local directory or + // 'acd' is set. + if (curwin != wp + && (curwin->w_localdir != NULL + || wp->w_localdir != NULL + || (curtab != tp + && (curtab->tp_localdir != NULL + || tp->tp_localdir != NULL)) +#ifdef FEAT_AUTOCHDIR + || p_acd +#endif + )) + cwd_status = mch_dirname(cwd, MAXPATHL); #ifdef FEAT_AUTOCHDIR // If 'acd' is set, check we are using that directory. If yes, then |