mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-26 12:53:13 +00:00
wildcard: Remove useless access() call for trailing slash
This confirmed that a file existed via access(file, F_OK). But we already *know* that it does because this is the expansion for the "trailing slash" - by definition all wildcard components up to here have already been checked. And it's not checking for directoryness either because it does F_OK. This will remove one `access()` per result, which will cut the number of syscalls needed for a glob that ends in a "/" in half. This brings us on-par with e.g. `ls` (which uses statx while we use newfstatat, but that should have about the same results) Fixes #9891.
This commit is contained in:
parent
861da91bf1
commit
6823f5e337
1 changed files with 2 additions and 5 deletions
|
@ -679,11 +679,8 @@ void wildcard_expander_t::expand_trailing_slash(const wcstring &base_dir, const
|
|||
}
|
||||
|
||||
if (!(flags & expand_flag::for_completions)) {
|
||||
// Trailing slash and not accepting incomplete, e.g. `echo /xyz/`. Insert this file if it
|
||||
// exists.
|
||||
if (waccess(base_dir, F_OK) == 0) {
|
||||
this->add_expansion_result(wcstring{base_dir});
|
||||
}
|
||||
// Trailing slash and not accepting incomplete, e.g. `echo /xyz/`. Insert this file, we already know it exists!
|
||||
this->add_expansion_result(wcstring{base_dir});
|
||||
} else {
|
||||
// Trailing slashes and accepting incomplete, e.g. `echo /xyz/<tab>`. Everything is added.
|
||||
dir_iter_t dir = open_dir(base_dir);
|
||||
|
|
Loading…
Reference in a new issue