make indexing parallel again

This commit is contained in:
Aleksey Kladov 2018-10-24 16:13:17 +03:00
parent b636d23bec
commit 44c8ddf885
2 changed files with 5 additions and 4 deletions

View File

@ -3,6 +3,7 @@
use ra_editor::LineIndex;
use ra_syntax::File;
use rustc_hash::FxHashSet;
use rayon::prelude::*;
use salsa::Database;
use crate::{
@ -105,8 +106,8 @@ pub(crate) fn new(
.set((), Arc::new(db::FileSet { files: file_ids, resolver }));
let file_set = db.file_set();
let symbol_index =
SymbolIndex::for_files(file_set.files.iter() // TODO: par iter
.map(|&file_id| (file_id, db.file_syntax(file_id))));
SymbolIndex::for_files(file_set.files.par_iter()
.map_with(db.clone(), |db, &file_id| (file_id, db.file_syntax(file_id))));
ReadonlySourceRoot { db, symbol_index: Arc::new(symbol_index) }
}

View File

@ -34,7 +34,7 @@ fn hash<H: Hasher>(&self, hasher: &mut H) {
}
impl SymbolIndex {
pub(crate) fn for_files(files: impl Iterator<Item = (FileId, File)>) -> SymbolIndex {
pub(crate) fn for_files(files: impl ParallelIterator<Item = (FileId, File)>) -> SymbolIndex {
let mut symbols = files
.flat_map(|(file_id, file)| {
file_symbols(&file)
@ -52,7 +52,7 @@ pub(crate) fn for_files(files: impl Iterator<Item = (FileId, File)>) -> SymbolIn
}
pub(crate) fn for_file(file_id: FileId, file: File) -> SymbolIndex {
SymbolIndex::for_files(::std::iter::once((file_id, file)))
SymbolIndex::for_files(rayon::iter::once((file_id, file)))
}
}