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/src/lib.rs | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'vfs/src') 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