# HG changeset patch # User Bram Moolenaar # Date 1641905104 -3600 # Node ID 3bad1cf600ed7fd3e1f70f4bba8abe119e4a3f2a # Parent 7ff6cfb317283ba474929b10884e41ea252a868f patch 8.2.4060: win_execute() slow on systems where getcwd()/chdir() is slow Commit: https://github.com/vim/vim/commit/d6f27c66cca32b93fcf8024b1bad1618946bbbea Author: Bram Moolenaar Date: Tue Jan 11 12:37:20 2022 +0000 patch 8.2.4060: win_execute() slow on systems where getcwd()/chdir() is slow 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) diff --git a/src/evalwindow.c b/src/evalwindow.c --- a/src/evalwindow.c +++ b/src/evalwindow.c @@ -707,13 +707,26 @@ f_win_execute(typval_T *argvars, typval_ { 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 diff --git a/src/version.c b/src/version.c --- a/src/version.c +++ b/src/version.c @@ -751,6 +751,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 4060, +/**/ 4059, /**/ 4058,