From 44c8ddf885daaecfa4785e100ac1b065126c05b7 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 24 Oct 2018 16:13:17 +0300 Subject: make indexing parallel again --- crates/ra_analysis/src/roots.rs | 5 +++-- crates/ra_analysis/src/symbol_index.rs | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) (limited to 'crates') 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}; use ra_editor::LineIndex; use ra_syntax::File; use rustc_hash::FxHashSet; +use rayon::prelude::*; use salsa::Database; use crate::{ @@ -105,8 +106,8 @@ impl ReadonlySourceRoot { .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) } } 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 { } impl SymbolIndex { - pub(crate) fn for_files(files: impl Iterator) -> SymbolIndex { + pub(crate) fn for_files(files: impl ParallelIterator) -> SymbolIndex { let mut symbols = files .flat_map(|(file_id, file)| { file_symbols(&file) @@ -52,7 +52,7 @@ impl SymbolIndex { } 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))) } } -- cgit v1.2.3