@@ -8,6 +8,7 @@ use crate::{
8
8
CrateId , ModuleDefId , ModuleId ,
9
9
} ;
10
10
use hir_expand:: name:: { known, AsName , Name } ;
11
+ use std:: sync:: Arc ;
11
12
use test_utils:: tested_by;
12
13
13
14
const MAX_PATH_LEN : usize = 15 ;
@@ -45,6 +46,7 @@ impl ModPath {
45
46
/// Find a path that can be used to refer to a certain item. This can depend on
46
47
/// *from where* you're referring to the item, hence the `from` parameter.
47
48
pub fn find_path ( db : & dyn DefDatabase , item : ItemInNs , from : ModuleId ) -> Option < ModPath > {
49
+ let _p = ra_prof:: profile ( "find_path" ) ;
48
50
find_path_inner ( db, item, from, MAX_PATH_LEN )
49
51
}
50
52
@@ -198,7 +200,7 @@ fn find_importable_locations(
198
200
. chain ( crate_graph[ from. krate ] . dependencies . iter ( ) . map ( |dep| dep. crate_id ) )
199
201
{
200
202
result. extend (
201
- importable_locations_in_crate ( db , item, krate)
203
+ db . importable_locations_of ( item, krate)
202
204
. iter ( )
203
205
. filter ( |( _, _, vis) | vis. is_visible_from ( db, from) )
204
206
. map ( |( m, n, _) | ( * m, n. clone ( ) ) ) ,
@@ -213,11 +215,11 @@ fn find_importable_locations(
213
215
///
214
216
/// Note that the crate doesn't need to be the one in which the item is defined;
215
217
/// it might be re-exported in other crates.
216
- fn importable_locations_in_crate (
218
+ pub ( crate ) fn importable_locations_in_crate (
217
219
db : & dyn DefDatabase ,
218
220
item : ItemInNs ,
219
221
krate : CrateId ,
220
- ) -> Vec < ( ModuleId , Name , Visibility ) > {
222
+ ) -> Arc < [ ( ModuleId , Name , Visibility ) ] > {
221
223
let def_map = db. crate_def_map ( krate) ;
222
224
let mut result = Vec :: new ( ) ;
223
225
for ( local_id, data) in def_map. modules . iter ( ) {
@@ -243,7 +245,8 @@ fn importable_locations_in_crate(
243
245
result. push ( ( ModuleId { krate, local_id } , name. clone ( ) , vis) ) ;
244
246
}
245
247
}
246
- result
248
+
249
+ Arc :: from ( result)
247
250
}
248
251
249
252
#[ cfg( test) ]
0 commit comments