diff options
author | Akshay <[email protected]> | 2022-02-19 15:14:59 +0000 |
---|---|---|
committer | Akshay <[email protected]> | 2022-02-19 15:14:59 +0000 |
commit | a80e252193096f22ae79fa03e66a0853ddae050e (patch) | |
tree | 710796b5feb58173e7c685b432f4654e8ad84e10 /vfs | |
parent | 2aec51a44015e9d466cd4bde3951e4f7e31db0cc (diff) |
parallelize statix-check
Diffstat (limited to 'vfs')
-rw-r--r-- | vfs/Cargo.toml | 2 | ||||
-rw-r--r-- | vfs/src/lib.rs | 8 |
2 files changed, 9 insertions, 1 deletions
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" | |||
6 | 6 | ||
7 | [dependencies] | 7 | [dependencies] |
8 | indexmap = "1.6.2" | 8 | indexmap = "1.6.2" |
9 | 9 | 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::{ | |||
5 | }; | 5 | }; |
6 | 6 | ||
7 | use indexmap::IndexSet; | 7 | use indexmap::IndexSet; |
8 | use rayon::prelude::*; | ||
8 | 9 | ||
9 | #[derive(Copy, Clone, Debug, PartialEq, PartialOrd, Eq, Ord, Hash)] | 10 | #[derive(Copy, Clone, Debug, PartialEq, PartialOrd, Eq, Ord, Hash)] |
10 | pub struct FileId(pub u32); | 11 | pub struct FileId(pub u32); |
@@ -70,6 +71,13 @@ impl ReadOnlyVfs { | |||
70 | contents: self.get_str(*file_id), | 71 | contents: self.get_str(*file_id), |
71 | }) | 72 | }) |
72 | } | 73 | } |
74 | pub fn par_iter(&self) -> impl ParallelIterator<Item = VfsEntry> { | ||
75 | self.data.par_iter().map(move |(file_id, _)| VfsEntry { | ||
76 | file_id: *file_id, | ||
77 | file_path: self.file_path(*file_id), | ||
78 | contents: self.get_str(*file_id), | ||
79 | }) | ||
80 | } | ||
73 | } | 81 | } |
74 | 82 | ||
75 | pub struct VfsEntry<'ρ> { | 83 | pub struct VfsEntry<'ρ> { |