Directory walkers key visited directories by (dev, inode); stats skips non-regular or oversized .rs targets

This commit is contained in:
Dylan M. Taylor
2026-11-03 17:32:44 +00:00
parent df137b8ee8
commit ecfed2acaa
2 changed files with 9 additions and 6 deletions
+2 -3
View File
@@ -278,7 +278,7 @@ fn collect_inputs(inputs: &[String]) -> Discovery {
}
/// Returns false only when the global file budget stops traversal.
fn walk(dir: &Path, depth: usize, out: &mut Discovery, seen: &mut std::collections::HashSet<u64>) -> bool {
fn walk(dir: &Path, depth: usize, out: &mut Discovery, seen: &mut std::collections::HashSet<(u64, u64)>) -> bool {
// A directory is visited once by identity (dev+inode on unix): several links to the same
// directory are aliases, not exponential branches of the scan. Other platforms keep the
// depth cap only.
@@ -286,8 +286,7 @@ fn walk(dir: &Path, depth: usize, out: &mut Discovery, seen: &mut std::collectio
{
use std::os::unix::fs::MetadataExt as _;
if let Ok(m) = std::fs::metadata(dir)
&& let Some(id) = m.dev().checked_mul(1 << 60).and_then(|d| d.checked_add(m.ino()))
&& !seen.insert(id)
&& !seen.insert((m.dev(), m.ino()))
{
return true;
}