From a80e252193096f22ae79fa03e66a0853ddae050e Mon Sep 17 00:00:00 2001 From: Akshay Date: Sat, 19 Feb 2022 20:44:59 +0530 Subject: parallelize statix-check --- bin/Cargo.toml | 9 +++++---- bin/src/lint.rs | 9 +++++++-- 2 files changed, 12 insertions(+), 6 deletions(-) (limited to 'bin') diff --git a/bin/Cargo.toml b/bin/Cargo.toml index bf39a3a..715e466 100644 --- a/bin/Cargo.toml +++ b/bin/Cargo.toml @@ -16,14 +16,15 @@ path = "src/main.rs" [dependencies] ariadne = "0.1.3" -rnix = "0.10.1" clap = "3.0.0-beta.4" ignore = "0.4.18" -thiserror = "1.0.30" -similar = "2.1.0" -vfs = { path = "../vfs" } lib = { path = "../lib" } +rayon = "1.5.1" +rnix = "0.10.1" +similar = "2.1.0" +thiserror = "1.0.30" toml = "0.5.8" +vfs = { path = "../vfs" } [dependencies.serde] version = "1.0.68" diff --git a/bin/src/lint.rs b/bin/src/lint.rs index 23a1d10..e1544e1 100644 --- a/bin/src/lint.rs +++ b/bin/src/lint.rs @@ -50,6 +50,7 @@ pub mod main { }; use lib::session::SessionInfo; + use rayon::prelude::*; pub fn main(check_config: CheckConfig) -> Result<(), StatixErr> { let vfs = check_config.vfs()?; @@ -59,9 +60,13 @@ pub mod main { let version = conf_file.version()?; let session = SessionInfo::from_version(version); let lint = |vfs_entry| lint_with(vfs_entry, &lints, &session); - let results = vfs.iter().map(lint).collect::>(); + let results = vfs + .par_iter() + .map(lint) + .filter(|lr| !lr.reports.is_empty()) + .collect::>(); - if results.iter().map(|r| r.reports.len()).sum::() != 0 { + if results.len() != 0 { for r in &results { stdout.write(&r, &vfs, check_config.format).unwrap(); } -- cgit v1.2.3