mirror of
https://github.com/bootandy/dust.git
synced 2026-06-08 11:29:05 +03:00
Rewrite to use walkdir instead of recursion
Advised to use walkdir by burntsushi as using recursion on file systems can blow the stack. walkdir is slower but allows the code to be cleaner and more reliable Also experimented with ignore but locking the hashmap resulted in similar performance to walkdir but with much uglier code.
This commit is contained in:
+4
-5
@@ -1,15 +1,14 @@
|
||||
#[macro_use]
|
||||
extern crate clap;
|
||||
extern crate assert_cli;
|
||||
extern crate walkdir;
|
||||
|
||||
use self::display::draw_it;
|
||||
use clap::{App, AppSettings, Arg};
|
||||
use utils::{find_big_ones, get_dir_tree};
|
||||
|
||||
|
||||
mod display;
|
||||
mod utils;
|
||||
mod lib;
|
||||
|
||||
static DEFAULT_NUMBER_OF_LINES: &'static str = "15";
|
||||
|
||||
@@ -40,9 +39,9 @@ fn main() {
|
||||
let number_of_lines = value_t!(options.value_of("number_of_lines"), usize).unwrap();
|
||||
let use_apparent_size = options.is_present("use_apparent_size");
|
||||
|
||||
let (permissions, node_per_top_level_dir) = get_dir_tree(&filenames, use_apparent_size);
|
||||
let slice_it = find_big_ones(&node_per_top_level_dir, number_of_lines);
|
||||
draw_it(permissions, &node_per_top_level_dir, &slice_it);
|
||||
let (permissions, nodes) = get_dir_tree(&filenames, use_apparent_size);
|
||||
let biggest_ones = find_big_ones(nodes, number_of_lines);
|
||||
draw_it(permissions, filenames, biggest_ones);
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
Reference in New Issue
Block a user