Skip to content
Myr

perf: Avoid unnecessary syscall for ignore-contain

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Instead of calling `is_dir` on the path, call it on the file_type of the DirEntry, since we should already have that information without needing to do another syscall.

authored by Thayne McCombs · committed by Thayne McCombs · parent b691572 · Browse files · 1 file+11 added−5 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Trailers

  • Fixes: #1913

Diff stats

1 file+11 added−5 removed

  • other:+11 added−5 removed

1 file+11 added−5 removed

modified:src/walk.rs+11 added-5 removed
460 unmodified lines
461 return WalkState::Quit;462 }463464 if let Ok(e) = &entry {465 let entry_path = e.path();466 if entry_path.is_dir()467 && config465 // If the entry is a directory that contains a466 // "ignore contain" file", we want to skip this467 // directory.468 // Check the filetype first to avoid unnecessary469 // syscalls.470 if e.file_type().is_some_and(|t| t.is_dir()) {471 let entry_path = e.path();472 if config473 .ignore_contain474 .iter()475 .any(|ic| entry_path.join(ic).exists())471 {472 return WalkState::Skip;476 {477 return WalkState::Skip;478 }479 }480 if e.depth() == 0 {481 // Skip the root directory entry.482 return WalkState::Continue;
204 unmodified lines