Only construct entry_path if needed
@@ -191,8 +191,6 @@ pub fn scan(path_vec: &[PathBuf], pattern: Arc<Regex>, config: Arc<FdOptions>) {
Err(_) => return ignore::WalkState::Continue,
};
- let entry_path = entry.path();
-
if entry.depth() == 0 {
return ignore::WalkState::Continue;
}
@@ -211,6 +209,8 @@ pub fn scan(path_vec: &[PathBuf], pattern: Arc<Regex>, config: Arc<FdOptions>) {
}
}
+ let entry_path = entry.path();
+
// Filter out unwanted extensions.
if let Some(ref exts_regex) = config.extensions {
if let Some(path_str) = entry_path.file_name().map_or(None, |s| s.to_str()) {
