From b4c571d0341fdc5f523b134d23aed9915a3f29a4 Mon Sep 17 00:00:00 2001 From: sharkdp Date: Sun, 4 Nov 2018 20:21:19 +0100 Subject: Use symlink_metadata for a huge speedup --- src/walk.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/walk.rs b/src/walk.rs index b80df07..9b660d7 100644 --- a/src/walk.rs +++ b/src/walk.rs @@ -14,7 +14,7 @@ type SizeEntry = (Option, u64); fn walk(tx: channel::Sender, entries: &[PathBuf]) { entries.into_par_iter().for_each_with(tx, |tx_ref, entry| { - if let Ok(metadata) = entry.metadata() { + if let Ok(metadata) = entry.symlink_metadata() { // If the entry has more than one hard link, generate // a unique ID consisting of device and inode in order // not to count this entry twice. @@ -32,15 +32,14 @@ fn walk(tx: channel::Sender, entries: &[PathBuf]) { let mut children = vec![]; for child_entry in fs::read_dir(entry).unwrap() { if let Ok(child_entry) = child_entry { - let path = child_entry.path(); - children.push(PathBuf::from(path)); + children.push(child_entry.path()); } } walk(tx_ref.clone(), &children[..]); }; } else { - eprintln!("Could not get metadata: '{}'", entry.to_string_lossy()); + eprintln!("Could not get file metadata: '{}'", entry.to_string_lossy()); }; }); } -- cgit v1.2.3