aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2018-10-24 14:13:17 +0100
committerAleksey Kladov <[email protected]>2018-10-24 14:13:17 +0100
commit44c8ddf885daaecfa4785e100ac1b065126c05b7 (patch)
tree1852cf05df754530636d58797e24f583e32617d2 /crates
parentb636d23bec0dcc6f85595787b8295c24df2bacfe (diff)
make indexing parallel again
Diffstat (limited to 'crates')
-rw-r--r--crates/ra_analysis/src/roots.rs5
-rw-r--r--crates/ra_analysis/src/symbol_index.rs4
2 files changed, 5 insertions, 4 deletions
diff --git a/crates/ra_analysis/src/roots.rs b/crates/ra_analysis/src/roots.rs
index 7100f7c71..15081f555 100644
--- a/crates/ra_analysis/src/roots.rs
+++ b/crates/ra_analysis/src/roots.rs
@@ -3,6 +3,7 @@ use std::{sync::Arc};
3use ra_editor::LineIndex; 3use ra_editor::LineIndex;
4use ra_syntax::File; 4use ra_syntax::File;
5use rustc_hash::FxHashSet; 5use rustc_hash::FxHashSet;
6use rayon::prelude::*;
6use salsa::Database; 7use salsa::Database;
7 8
8use crate::{ 9use crate::{
@@ -105,8 +106,8 @@ impl ReadonlySourceRoot {
105 .set((), Arc::new(db::FileSet { files: file_ids, resolver })); 106 .set((), Arc::new(db::FileSet { files: file_ids, resolver }));
106 let file_set = db.file_set(); 107 let file_set = db.file_set();
107 let symbol_index = 108 let symbol_index =
108 SymbolIndex::for_files(file_set.files.iter() // TODO: par iter 109 SymbolIndex::for_files(file_set.files.par_iter()
109 .map(|&file_id| (file_id, db.file_syntax(file_id)))); 110 .map_with(db.clone(), |db, &file_id| (file_id, db.file_syntax(file_id))));
110 111
111 ReadonlySourceRoot { db, symbol_index: Arc::new(symbol_index) } 112 ReadonlySourceRoot { db, symbol_index: Arc::new(symbol_index) }
112 } 113 }
diff --git a/crates/ra_analysis/src/symbol_index.rs b/crates/ra_analysis/src/symbol_index.rs
index 1b7d9f779..e5c8d8870 100644
--- a/crates/ra_analysis/src/symbol_index.rs
+++ b/crates/ra_analysis/src/symbol_index.rs
@@ -34,7 +34,7 @@ impl Hash for SymbolIndex {
34} 34}
35 35
36impl SymbolIndex { 36impl SymbolIndex {
37 pub(crate) fn for_files(files: impl Iterator<Item = (FileId, File)>) -> SymbolIndex { 37 pub(crate) fn for_files(files: impl ParallelIterator<Item = (FileId, File)>) -> SymbolIndex {
38 let mut symbols = files 38 let mut symbols = files
39 .flat_map(|(file_id, file)| { 39 .flat_map(|(file_id, file)| {
40 file_symbols(&file) 40 file_symbols(&file)
@@ -52,7 +52,7 @@ impl SymbolIndex {
52 } 52 }
53 53
54 pub(crate) fn for_file(file_id: FileId, file: File) -> SymbolIndex { 54 pub(crate) fn for_file(file_id: FileId, file: File) -> SymbolIndex {
55 SymbolIndex::for_files(::std::iter::once((file_id, file))) 55 SymbolIndex::for_files(rayon::iter::once((file_id, file)))
56 } 56 }
57} 57}
58 58