Closed
Description
It calls .shift
on a vector repeatedly.
Example:
// walk_dir.rs
fn main() {
let dir = Path::new(std::os::args()[1]);
for _ in std::io::fs::walk_dir(&dir).unwrap() {}
}
$ n=50000; mkdir -p $n; bash -c "touch $n/{1..$n}"
$ time ./walk_dir 50000/
real 0m1.442s
user 0m1.404s
sys 0m0.032s
$ n=100000; mkdir -p $n; bash -c "touch $n/{1..$n}"
$ time ./walk_dir 100000/
real 0m6.228s
user 0m6.096s
sys 0m0.132s
50000
and 100000
are directories with that many files in them. Theoretically this wants a deque.