mirror of
https://github.com/fish-shell/fish-shell
synced 2025-02-13 12:43:43 +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.
(cherry picked from commit 6823f5e337
)
This commit is contained in:
parent
72edd888f1
commit
9892ce3a5a
1 changed files with 2 additions and 5 deletions
|
@ -676,11 +676,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…
Add table
Reference in a new issue