@@ -241,6 +241,26 @@ impl SerializedSearchIndex {
241
241
self . alias_pointers . push ( alias_pointer) ;
242
242
index
243
243
}
244
+ fn add_entry ( & mut self , name : Symbol , entry_data : EntryData , desc : String ) -> usize {
245
+ let fqp = if let Some ( module_path_index) = entry_data. module_path {
246
+ let mut fqp = self . path_data [ module_path_index] . as_ref ( ) . unwrap ( ) . module_path . clone ( ) ;
247
+ fqp. push ( Symbol :: intern ( & self . names [ module_path_index] ) ) ;
248
+ fqp. push ( name) ;
249
+ fqp
250
+ } else {
251
+ vec ! [ name]
252
+ } ;
253
+ if let Some ( & other_path) = self . crate_paths_index . get ( & ( entry_data. ty , fqp) )
254
+ && self . entry_data [ other_path] . is_none ( )
255
+ && self . descs [ other_path] . is_empty ( )
256
+ {
257
+ self . entry_data [ other_path] = Some ( entry_data) ;
258
+ self . descs [ other_path] = desc;
259
+ other_path
260
+ } else {
261
+ self . push ( name. as_str ( ) . to_string ( ) , None , Some ( entry_data) , desc, None , None , None )
262
+ }
263
+ }
244
264
fn push_path ( & mut self , name : String , path_data : PathData ) -> usize {
245
265
self . push ( name, Some ( path_data) , None , String :: new ( ) , None , None , None )
246
266
}
@@ -1516,10 +1536,9 @@ pub(crate) fn build_index(
1516
1536
. as_ref ( )
1517
1537
. map ( |path| serialized_index. get_id_by_module_path ( path) ) ;
1518
1538
1519
- let new_entry_id = serialized_index. push (
1520
- item. name . as_str ( ) . to_string ( ) ,
1521
- None ,
1522
- Some ( EntryData {
1539
+ let new_entry_id = serialized_index. add_entry (
1540
+ item. name ,
1541
+ EntryData {
1523
1542
ty : item. ty ,
1524
1543
parent : item. parent_idx ,
1525
1544
module_path,
@@ -1538,11 +1557,8 @@ pub(crate) fn build_index(
1538
1557
None
1539
1558
} ,
1540
1559
krate : crate_idx,
1541
- } ) ,
1560
+ } ,
1542
1561
item. desc . to_string ( ) ,
1543
- None , // filled in after all the types have been indexed
1544
- None ,
1545
- None ,
1546
1562
) ;
1547
1563
1548
1564
// Aliases
0 commit comments