@@ -49,7 +49,6 @@ use encode::{bitmap_to_string, write_vlqhex_to_string};
4949pub ( crate ) struct SerializedSearchIndex {
5050 pub ( crate ) index : String ,
5151 pub ( crate ) desc : Vec < ( usize , String ) > ,
52- pub ( crate ) param_names : String ,
5352}
5453
5554const DESC_INDEX_SHARD_LEN : usize = 128 * 1024 ;
@@ -622,9 +621,25 @@ pub(crate) fn build_index<'tcx>(
622621 full_paths. push ( ( * index, path) ) ;
623622 }
624623
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+
625640 let has_aliases = !self . aliases . is_empty ( ) ;
626641 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 } ) ?;
628643 crate_data. serialize_field ( "t" , & types) ?;
629644 crate_data. serialize_field ( "n" , & names) ?;
630645 crate_data. serialize_field ( "q" , & full_paths) ?;
@@ -636,6 +651,7 @@ pub(crate) fn build_index<'tcx>(
636651 crate_data. serialize_field ( "b" , & self . associated_item_disambiguators ) ?;
637652 crate_data. serialize_field ( "c" , & bitmap_to_string ( & deprecated) ) ?;
638653 crate_data. serialize_field ( "e" , & bitmap_to_string ( & self . empty_desc ) ) ?;
654+ crate_data. serialize_field ( "P" , & param_names) ?;
639655 if has_aliases {
640656 crate_data. serialize_field ( "a" , & self . aliases ) ?;
641657 }
@@ -682,23 +698,6 @@ pub(crate) fn build_index<'tcx>(
682698 desc. iter( ) . map( |( len, _) | * len) . sum:: <usize >( ) + empty_desc. len( )
683699 ) ;
684700
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-
702701 // The index, which is actually used to search, is JSON
703702 // It uses `JSON.parse(..)` to actually load, since JSON
704703 // parses faster than the full JavaScript syntax.
@@ -720,7 +719,7 @@ pub(crate) fn build_index<'tcx>(
720719 // We need to escape double quotes for the JSON.
721720 . replace( "\\ \" " , "\\ \\ \" " )
722721 ) ;
723- SerializedSearchIndex { index, desc, param_names }
722+ SerializedSearchIndex { index, desc }
724723}
725724
726725pub ( crate ) fn get_function_type_for_search < ' tcx > (
0 commit comments