@@ -10,6 +10,7 @@ use ra_syntax::{
10
10
SyntaxKind :: * ,
11
11
SyntaxNodeRef , TextRange , TextUnit ,
12
12
} ;
13
+ use rayon:: prelude:: * ;
13
14
use relative_path:: RelativePath ;
14
15
use rustc_hash:: FxHashSet ;
15
16
use salsa:: { ParallelDatabase , Database } ;
@@ -23,6 +24,7 @@ use crate::{
23
24
input:: { SourceRootId , FilesDatabase , SourceRoot , WORKSPACE } ,
24
25
descriptors:: module:: { ModulesDatabase , ModuleTree , Problem } ,
25
26
descriptors:: { FnDescriptor } ,
27
+ symbol_index:: SymbolIndex ,
26
28
CrateGraph , CrateId , Diagnostic , FileId , FileResolver , FileSystemEdit , Position ,
27
29
Query , SourceChange , SourceFileEdit , Cancelable ,
28
30
} ;
@@ -180,16 +182,18 @@ impl AnalysisImpl {
180
182
self . db . file_lines ( file_id)
181
183
}
182
184
pub fn world_symbols ( & self , query : Query ) -> Cancelable < Vec < ( FileId , FileSymbol ) > > {
183
- let mut buf = Vec :: new ( ) ;
184
- if query. libs {
185
- for & lib_id in self . db . libraries ( ) . iter ( ) {
186
- buf. push ( self . db . library_symbols ( lib_id) ) ;
187
- }
185
+ let buf: Vec < Arc < SymbolIndex > > = if query. libs {
186
+ self . db . libraries ( ) . iter ( )
187
+ . map ( |& lib_id| self . db . library_symbols ( lib_id) )
188
+ . collect ( )
188
189
} else {
189
- for & file_id in self . db . source_root ( WORKSPACE ) . files . iter ( ) {
190
- buf. push ( self . db . file_symbols ( file_id) ?) ;
191
- }
192
- }
190
+ let files = & self . db . source_root ( WORKSPACE ) . files ;
191
+ let db = self . db . clone ( ) ;
192
+ files. par_iter ( )
193
+ . map_with ( db, |db, & file_id| db. file_symbols ( file_id) )
194
+ . filter_map ( |it| it. ok ( ) )
195
+ . collect ( )
196
+ } ;
193
197
Ok ( query. search ( & buf) )
194
198
}
195
199
fn module_tree ( & self , file_id : FileId ) -> Cancelable < Arc < ModuleTree > > {
0 commit comments