From a80e252193096f22ae79fa03e66a0853ddae050e Mon Sep 17 00:00:00 2001 From: Akshay Date: Sat, 19 Feb 2022 20:44:59 +0530 Subject: parallelize statix-check --- vfs/Cargo.toml | 2 +- vfs/src/lib.rs | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) (limited to 'vfs') diff --git a/vfs/Cargo.toml b/vfs/Cargo.toml index 7a5dc6b..d1d654c 100644 --- a/vfs/Cargo.toml +++ b/vfs/Cargo.toml @@ -6,4 +6,4 @@ license = "MIT" [dependencies] indexmap = "1.6.2" - +rayon = "1.5.1" diff --git a/vfs/src/lib.rs b/vfs/src/lib.rs index cd6cc03..2d7577d 100644 --- a/vfs/src/lib.rs +++ b/vfs/src/lib.rs @@ -5,6 +5,7 @@ use std::{ }; use indexmap::IndexSet; +use rayon::prelude::*; #[derive(Copy, Clone, Debug, PartialEq, PartialOrd, Eq, Ord, Hash)] pub struct FileId(pub u32); @@ -70,6 +71,13 @@ impl ReadOnlyVfs { contents: self.get_str(*file_id), }) } + pub fn par_iter(&self) -> impl ParallelIterator { + self.data.par_iter().map(move |(file_id, _)| VfsEntry { + file_id: *file_id, + file_path: self.file_path(*file_id), + contents: self.get_str(*file_id), + }) + } } pub struct VfsEntry<'ρ> { -- cgit v1.2.3