@@ -49,7 +49,6 @@ use encode::{bitmap_to_string, write_vlqhex_to_string};
49
49
pub ( crate ) struct SerializedSearchIndex {
50
50
pub ( crate ) index : String ,
51
51
pub ( crate ) desc : Vec < ( usize , String ) > ,
52
- pub ( crate ) param_names : String ,
53
52
}
54
53
55
54
const DESC_INDEX_SHARD_LEN : usize = 128 * 1024 ;
@@ -622,9 +621,25 @@ pub(crate) fn build_index<'tcx>(
622
621
full_paths. push ( ( * index, path) ) ;
623
622
}
624
623
624
+ let param_names: Vec < ( usize , String ) > = {
625
+ let mut prev = Vec :: new ( ) ;
626
+ let mut result = Vec :: new ( ) ;
627
+ for ( index, item) in self . items . iter ( ) . enumerate ( ) {
628
+ if let Some ( ty) = & item. search_type
629
+ && let my =
630
+ ty. param_names . iter ( ) . map ( |sym| sym. as_str ( ) ) . collect :: < Vec < _ > > ( )
631
+ && my != prev
632
+ {
633
+ result. push ( ( index, my. join ( "," ) ) ) ;
634
+ prev = my;
635
+ }
636
+ }
637
+ result
638
+ } ;
639
+
625
640
let has_aliases = !self . aliases . is_empty ( ) ;
626
641
let mut crate_data =
627
- serializer. serialize_struct ( "CrateData" , if has_aliases { 9 } else { 8 } ) ?;
642
+ serializer. serialize_struct ( "CrateData" , if has_aliases { 13 } else { 12 } ) ?;
628
643
crate_data. serialize_field ( "t" , & types) ?;
629
644
crate_data. serialize_field ( "n" , & names) ?;
630
645
crate_data. serialize_field ( "q" , & full_paths) ?;
@@ -636,6 +651,7 @@ pub(crate) fn build_index<'tcx>(
636
651
crate_data. serialize_field ( "b" , & self . associated_item_disambiguators ) ?;
637
652
crate_data. serialize_field ( "c" , & bitmap_to_string ( & deprecated) ) ?;
638
653
crate_data. serialize_field ( "e" , & bitmap_to_string ( & self . empty_desc ) ) ?;
654
+ crate_data. serialize_field ( "P" , & param_names) ?;
639
655
if has_aliases {
640
656
crate_data. serialize_field ( "a" , & self . aliases ) ?;
641
657
}
@@ -682,23 +698,6 @@ pub(crate) fn build_index<'tcx>(
682
698
desc. iter( ) . map( |( len, _) | * len) . sum:: <usize >( ) + empty_desc. len( )
683
699
) ;
684
700
685
- let param_names = {
686
- let result: Vec < Vec < & str > > = crate_items
687
- . iter ( )
688
- . map ( |item| match & item. search_type {
689
- Some ( ty) => ty. param_names . iter ( ) . map ( |sym| sym. as_str ( ) ) . collect ( ) ,
690
- None => Vec :: new ( ) ,
691
- } )
692
- . collect ( ) ;
693
- serde_json:: to_string ( & result)
694
- . expect ( "failed serde conversion" )
695
- // All these `replace` calls are because we have to go through JS string for JSON content.
696
- . replace ( '\\' , r"\\" )
697
- . replace ( '\'' , r"\'" )
698
- // We need to escape double quotes for the JSON.
699
- . replace ( "\\ \" " , "\\ \\ \" " )
700
- } ;
701
-
702
701
// The index, which is actually used to search, is JSON
703
702
// It uses `JSON.parse(..)` to actually load, since JSON
704
703
// parses faster than the full JavaScript syntax.
@@ -720,7 +719,7 @@ pub(crate) fn build_index<'tcx>(
720
719
// We need to escape double quotes for the JSON.
721
720
. replace( "\\ \" " , "\\ \\ \" " )
722
721
) ;
723
- SerializedSearchIndex { index, desc, param_names }
722
+ SerializedSearchIndex { index, desc }
724
723
}
725
724
726
725
pub ( crate ) fn get_function_type_for_search < ' tcx > (
0 commit comments