@@ -120,7 +120,7 @@ crate struct Cache {
120
120
121
121
/// Aliases added through `#[doc(alias = "...")]`. Since a few items can have the same alias,
122
122
/// we need the alias element to have an array of items.
123
- pub ( super ) aliases : FxHashMap < String , Vec < usize > > ,
123
+ pub ( super ) aliases : BTreeMap < String , Vec < usize > > ,
124
124
}
125
125
126
126
impl Cache {
@@ -331,7 +331,7 @@ impl DocFolder for Cache {
331
331
for alias in item. attrs . get_doc_aliases ( ) {
332
332
self . aliases
333
333
. entry ( alias. to_lowercase ( ) )
334
- . or_insert ( Vec :: with_capacity ( 1 ) )
334
+ . or_insert ( Vec :: new ( ) )
335
335
. push ( self . search_index . len ( ) - 1 ) ;
336
336
}
337
337
}
@@ -553,10 +553,10 @@ fn build_index(krate: &clean::Crate, cache: &mut Cache) -> String {
553
553
parent_idx : None ,
554
554
search_type : get_index_search_type ( & item) ,
555
555
} ) ;
556
- for alias in item. attrs . get_doc_aliases ( ) . into_iter ( ) {
556
+ for alias in item. attrs . get_doc_aliases ( ) {
557
557
aliases
558
558
. entry ( alias. to_lowercase ( ) )
559
- . or_insert ( Vec :: with_capacity ( 1 ) )
559
+ . or_insert ( Vec :: new ( ) )
560
560
. push ( search_index. len ( ) - 1 ) ;
561
561
}
562
562
}
@@ -600,9 +600,6 @@ fn build_index(krate: &clean::Crate, cache: &mut Cache) -> String {
600
600
. map ( |module| shorten ( plain_summary_line ( module. doc_value ( ) ) ) )
601
601
. unwrap_or ( String :: new ( ) ) ;
602
602
603
- let crate_aliases =
604
- aliases. iter ( ) . map ( |( k, values) | ( k. clone ( ) , values. clone ( ) ) ) . collect :: < Vec < _ > > ( ) ;
605
-
606
603
#[ derive( Serialize ) ]
607
604
struct CrateData < ' a > {
608
605
doc : String ,
@@ -614,7 +611,8 @@ fn build_index(krate: &clean::Crate, cache: &mut Cache) -> String {
614
611
//
615
612
// To be noted: the `usize` elements are indexes to `items`.
616
613
#[ serde( rename = "a" ) ]
617
- aliases : Option < Vec < ( String , Vec < usize > ) > > ,
614
+ #[ serde( skip_serializing_if = "BTreeMap::is_empty" ) ]
615
+ aliases : & ' a BTreeMap < String , Vec < usize > > ,
618
616
}
619
617
620
618
// Collect the index into a string
@@ -625,7 +623,7 @@ fn build_index(krate: &clean::Crate, cache: &mut Cache) -> String {
625
623
doc: crate_doc,
626
624
items: crate_items,
627
625
paths: crate_paths,
628
- aliases: if crate_aliases . is_empty ( ) { None } else { Some ( crate_aliases ) } ,
626
+ aliases,
629
627
} )
630
628
. expect( "failed serde conversion" )
631
629
// All these `replace` calls are because we have to go through JS string for JSON content.
0 commit comments