@@ -48,7 +48,6 @@ use crate::html::render::{self, IndexItem, IndexItemFunctionType, RenderType, Re
4848pub ( crate ) struct SerializedSearchIndex {
4949 pub ( crate ) index : String ,
5050 pub ( crate ) desc : Vec < ( usize , String ) > ,
51- pub ( crate ) param_names : String ,
5251}
5352
5453const DESC_INDEX_SHARD_LEN : usize = 128 * 1024 ;
@@ -621,9 +620,25 @@ pub(crate) fn build_index<'tcx>(
621620 full_paths. push ( ( * index, path) ) ;
622621 }
623622
623+ let param_names: Vec < ( usize , String ) > = {
624+ let mut prev = Vec :: new ( ) ;
625+ let mut result = Vec :: new ( ) ;
626+ for ( index, item) in self . items . iter ( ) . enumerate ( ) {
627+ if let Some ( ty) = & item. search_type
628+ && let my =
629+ ty. param_names . iter ( ) . map ( |sym| sym. as_str ( ) ) . collect :: < Vec < _ > > ( )
630+ && my != prev
631+ {
632+ result. push ( ( index, my. join ( "," ) ) ) ;
633+ prev = my;
634+ }
635+ }
636+ result
637+ } ;
638+
624639 let has_aliases = !self . aliases . is_empty ( ) ;
625640 let mut crate_data =
626- serializer. serialize_struct ( "CrateData" , if has_aliases { 9 } else { 8 } ) ?;
641+ serializer. serialize_struct ( "CrateData" , if has_aliases { 13 } else { 12 } ) ?;
627642 crate_data. serialize_field ( "t" , & types) ?;
628643 crate_data. serialize_field ( "n" , & names) ?;
629644 crate_data. serialize_field ( "q" , & full_paths) ?;
@@ -635,6 +650,7 @@ pub(crate) fn build_index<'tcx>(
635650 crate_data. serialize_field ( "b" , & self . associated_item_disambiguators ) ?;
636651 crate_data. serialize_field ( "c" , & bitmap_to_string ( & deprecated) ) ?;
637652 crate_data. serialize_field ( "e" , & bitmap_to_string ( & self . empty_desc ) ) ?;
653+ crate_data. serialize_field ( "P" , & param_names) ?;
638654 if has_aliases {
639655 crate_data. serialize_field ( "a" , & self . aliases ) ?;
640656 }
@@ -681,23 +697,6 @@ pub(crate) fn build_index<'tcx>(
681697 desc. iter( ) . map( |( len, _) | * len) . sum:: <usize >( ) + empty_desc. len( )
682698 ) ;
683699
684- let param_names = {
685- let result: Vec < Vec < & str > > = crate_items
686- . iter ( )
687- . map ( |item| match & item. search_type {
688- Some ( ty) => ty. param_names . iter ( ) . map ( |sym| sym. as_str ( ) ) . collect ( ) ,
689- None => Vec :: new ( ) ,
690- } )
691- . collect ( ) ;
692- serde_json:: to_string ( & result)
693- . expect ( "failed serde conversion" )
694- // All these `replace` calls are because we have to go through JS string for JSON content.
695- . replace ( '\\' , r"\\" )
696- . replace ( '\'' , r"\'" )
697- // We need to escape double quotes for the JSON.
698- . replace ( "\\ \" " , "\\ \\ \" " )
699- } ;
700-
701700 // The index, which is actually used to search, is JSON
702701 // It uses `JSON.parse(..)` to actually load, since JSON
703702 // parses faster than the full JavaScript syntax.
@@ -719,7 +718,7 @@ pub(crate) fn build_index<'tcx>(
719718 // We need to escape double quotes for the JSON.
720719 . replace( "\\ \" " , "\\ \\ \" " )
721720 ) ;
722- SerializedSearchIndex { index, desc, param_names }
721+ SerializedSearchIndex { index, desc }
723722}
724723
725724pub ( crate ) fn get_function_type_for_search < ' tcx > (
0 commit comments