mirror of
https://github.com/neovim/neovim.git
synced 2025-10-10 03:46:31 +00:00
refactor: remove some chdir-related unnecessary calls and checks
xmalloc() always retuns a valid pointer. Calling os_chdir() with the same directory as the current one doesn't do anything other than wasting time.
This commit is contained in:
@@ -1082,15 +1082,13 @@ static void f_chdir(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||
|
||||
// Return the current directory
|
||||
cwd = xmalloc(MAXPATHL);
|
||||
if (cwd != NULL) {
|
||||
if (os_dirname(cwd, MAXPATHL) != FAIL) {
|
||||
if (os_dirname(cwd, MAXPATHL) != FAIL) {
|
||||
#ifdef BACKSLASH_IN_FILENAME
|
||||
slash_adjust(cwd);
|
||||
slash_adjust(cwd);
|
||||
#endif
|
||||
rettv->vval.v_string = vim_strsave(cwd);
|
||||
}
|
||||
xfree(cwd);
|
||||
rettv->vval.v_string = vim_strsave(cwd);
|
||||
}
|
||||
xfree(cwd);
|
||||
|
||||
if (curwin->w_localdir != NULL) {
|
||||
scope = kCdScopeWindow;
|
||||
|
Reference in New Issue
Block a user