diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/main.rs | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/main.rs b/src/main.rs index c776336..29f482f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -6,6 +6,7 @@ extern crate colored; extern crate evtclib; extern crate regex; extern crate walkdir; +extern crate rayon; use std::fs::File; use std::io::{self, BufReader}; @@ -17,6 +18,8 @@ use regex::Regex; use structopt::StructOpt; use walkdir::{DirEntry, WalkDir}; +use rayon::prelude::*; + use evtclib::{AgentKind, AgentName, EventKind, Log}; mod errors; @@ -103,16 +106,16 @@ fn is_log_file(entry: &DirEntry) -> bool { fn grep(opt: &Opt) -> Result<(), RuntimeError> { let walker = WalkDir::new(&opt.path); - for entry in walker { - let entry = entry?; + let entries = walker.into_iter().collect::<Vec<_>>(); + entries.into_par_iter().try_for_each(|e| { + let entry = e?; if is_log_file(&entry) { if let Some(result) = search_log(&entry, opt)? { output::colored(io::stdout(), &result)?; } } - } - - Ok(()) + Ok(()) + }) } fn search_log(entry: &DirEntry, opt: &Opt) -> Result<Option<LogResult>, RuntimeError> { |