Skip to content

Commit cb3fad4

Browse files
authored
Merge pull request #1914 from tmccombs/faster-ignore-contains
perf: Avoid unnecessary syscall for ignore-contain
2 parents b691572 + a4d86cc commit cb3fad4

1 file changed

Lines changed: 11 additions & 5 deletions

File tree

src/walk.rs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -462,14 +462,20 @@ impl WorkerState {
462462
}
463463

464464
if let Ok(e) = &entry {
465-
let entry_path = e.path();
466-
if entry_path.is_dir()
467-
&& config
465+
// If the entry is a directory that contains a
466+
// "ignore contain" file", we want to skip this
467+
// directory.
468+
// Check the filetype first to avoid unnecessary
469+
// syscalls.
470+
if e.file_type().is_some_and(|t| t.is_dir()) {
471+
let entry_path = e.path();
472+
if config
468473
.ignore_contain
469474
.iter()
470475
.any(|ic| entry_path.join(ic).exists())
471-
{
472-
return WalkState::Skip;
476+
{
477+
return WalkState::Skip;
478+
}
473479
}
474480
if e.depth() == 0 {
475481
// Skip the root directory entry.

0 commit comments

Comments
 (0)