mirror of
https://github.com/neovim/neovim.git
synced 2025-09-18 09:18:19 +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:
@@ -7816,8 +7816,9 @@ bool changedir_func(char_u *new_dir, CdScope scope)
|
||||
}
|
||||
#endif
|
||||
|
||||
if (vim_chdir(new_dir) == 0) {
|
||||
bool dir_differs = pdir == NULL || pathcmp((char *)pdir, (char *)new_dir, -1) != 0;
|
||||
bool dir_differs = new_dir == NULL || pdir == NULL
|
||||
|| pathcmp((char *)pdir, (char *)new_dir, -1) != 0;
|
||||
if (new_dir != NULL && (!dir_differs || vim_chdir(new_dir) == 0)) {
|
||||
post_chdir(scope, dir_differs);
|
||||
retval = true;
|
||||
} else {
|
||||
|
Reference in New Issue
Block a user