diff options
author | Aleksey Kladov <[email protected]> | 2018-10-29 10:32:45 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2018-10-29 10:32:45 +0000 |
commit | 35568cf057e116ef3471b3c5e50beeb2f6bc7e70 (patch) | |
tree | e678fcb6756d1967406a4ee46c0e0f896f9328a8 /crates/ra_analysis/src/imp.rs | |
parent | 943fc5e323fef4a3acda9364abd6ec72d05532e6 (diff) |
Index files in parallel
Diffstat (limited to 'crates/ra_analysis/src/imp.rs')
-rw-r--r-- | crates/ra_analysis/src/imp.rs | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/crates/ra_analysis/src/imp.rs b/crates/ra_analysis/src/imp.rs index 5a6e2450d..90446c838 100644 --- a/crates/ra_analysis/src/imp.rs +++ b/crates/ra_analysis/src/imp.rs | |||
@@ -10,6 +10,7 @@ use ra_syntax::{ | |||
10 | SyntaxKind::*, | 10 | SyntaxKind::*, |
11 | SyntaxNodeRef, TextRange, TextUnit, | 11 | SyntaxNodeRef, TextRange, TextUnit, |
12 | }; | 12 | }; |
13 | use rayon::prelude::*; | ||
13 | use relative_path::RelativePath; | 14 | use relative_path::RelativePath; |
14 | use rustc_hash::FxHashSet; | 15 | use rustc_hash::FxHashSet; |
15 | use salsa::{ParallelDatabase, Database}; | 16 | use salsa::{ParallelDatabase, Database}; |
@@ -23,6 +24,7 @@ use crate::{ | |||
23 | input::{SourceRootId, FilesDatabase, SourceRoot, WORKSPACE}, | 24 | input::{SourceRootId, FilesDatabase, SourceRoot, WORKSPACE}, |
24 | descriptors::module::{ModulesDatabase, ModuleTree, Problem}, | 25 | descriptors::module::{ModulesDatabase, ModuleTree, Problem}, |
25 | descriptors::{FnDescriptor}, | 26 | descriptors::{FnDescriptor}, |
27 | symbol_index::SymbolIndex, | ||
26 | CrateGraph, CrateId, Diagnostic, FileId, FileResolver, FileSystemEdit, Position, | 28 | CrateGraph, CrateId, Diagnostic, FileId, FileResolver, FileSystemEdit, Position, |
27 | Query, SourceChange, SourceFileEdit, Cancelable, | 29 | Query, SourceChange, SourceFileEdit, Cancelable, |
28 | }; | 30 | }; |
@@ -180,16 +182,18 @@ impl AnalysisImpl { | |||
180 | self.db.file_lines(file_id) | 182 | self.db.file_lines(file_id) |
181 | } | 183 | } |
182 | pub fn world_symbols(&self, query: Query) -> Cancelable<Vec<(FileId, FileSymbol)>> { | 184 | pub fn world_symbols(&self, query: Query) -> Cancelable<Vec<(FileId, FileSymbol)>> { |
183 | let mut buf = Vec::new(); | 185 | let buf: Vec<Arc<SymbolIndex>> = if query.libs { |
184 | if query.libs { | 186 | self.db.libraries().iter() |
185 | for &lib_id in self.db.libraries().iter() { | 187 | .map(|&lib_id| self.db.library_symbols(lib_id)) |
186 | buf.push(self.db.library_symbols(lib_id)); | 188 | .collect() |
187 | } | ||
188 | } else { | 189 | } else { |
189 | for &file_id in self.db.source_root(WORKSPACE).files.iter() { | 190 | let files = &self.db.source_root(WORKSPACE).files; |
190 | buf.push(self.db.file_symbols(file_id)?); | 191 | let db = self.db.clone(); |
191 | } | 192 | files.par_iter() |
192 | } | 193 | .map_with(db, |db, &file_id| db.file_symbols(file_id)) |
194 | .filter_map(|it| it.ok()) | ||
195 | .collect() | ||
196 | }; | ||
193 | Ok(query.search(&buf)) | 197 | Ok(query.search(&buf)) |
194 | } | 198 | } |
195 | fn module_tree(&self, file_id: FileId) -> Cancelable<Arc<ModuleTree>> { | 199 | fn module_tree(&self, file_id: FileId) -> Cancelable<Arc<ModuleTree>> { |