mirror of
https://github.com/sharkdp/fd.git
synced 2026-08-30 17:07:43 +08:00
Merge pull request #1914 from tmccombs/faster-ignore-contains
perf: Avoid unnecessary syscall for ignore-contain
This commit is contained in:
+11
-5
@@ -462,14 +462,20 @@ impl WorkerState {
|
||||
}
|
||||
|
||||
if let Ok(e) = &entry {
|
||||
let entry_path = e.path();
|
||||
if entry_path.is_dir()
|
||||
&& config
|
||||
// If the entry is a directory that contains a
|
||||
// "ignore contain" file", we want to skip this
|
||||
// directory.
|
||||
// Check the filetype first to avoid unnecessary
|
||||
// syscalls.
|
||||
if e.file_type().is_some_and(|t| t.is_dir()) {
|
||||
let entry_path = e.path();
|
||||
if config
|
||||
.ignore_contain
|
||||
.iter()
|
||||
.any(|ic| entry_path.join(ic).exists())
|
||||
{
|
||||
return WalkState::Skip;
|
||||
{
|
||||
return WalkState::Skip;
|
||||
}
|
||||
}
|
||||
if e.depth() == 0 {
|
||||
// Skip the root directory entry.
|
||||
|
||||
Reference in New Issue
Block a user