@@ -120,7 +120,7 @@ crate struct Cache {
120120
121121 /// Aliases added through `#[doc(alias = "...")]`. Since a few items can have the same alias,
122122 /// 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 > > ,
124124}
125125
126126impl Cache {
@@ -331,7 +331,7 @@ impl DocFolder for Cache {
331331 for alias in item. attrs . get_doc_aliases ( ) {
332332 self . aliases
333333 . entry ( alias. to_lowercase ( ) )
334- . or_insert ( Vec :: with_capacity ( 1 ) )
334+ . or_insert ( Vec :: new ( ) )
335335 . push ( self . search_index . len ( ) - 1 ) ;
336336 }
337337 }
@@ -553,10 +553,10 @@ fn build_index(krate: &clean::Crate, cache: &mut Cache) -> String {
553553 parent_idx : None ,
554554 search_type : get_index_search_type ( & item) ,
555555 } ) ;
556- for alias in item. attrs . get_doc_aliases ( ) . into_iter ( ) {
556+ for alias in item. attrs . get_doc_aliases ( ) {
557557 aliases
558558 . entry ( alias. to_lowercase ( ) )
559- . or_insert ( Vec :: with_capacity ( 1 ) )
559+ . or_insert ( Vec :: new ( ) )
560560 . push ( search_index. len ( ) - 1 ) ;
561561 }
562562 }
@@ -600,9 +600,6 @@ fn build_index(krate: &clean::Crate, cache: &mut Cache) -> String {
600600 . map ( |module| shorten ( plain_summary_line ( module. doc_value ( ) ) ) )
601601 . unwrap_or ( String :: new ( ) ) ;
602602
603- let crate_aliases =
604- aliases. iter ( ) . map ( |( k, values) | ( k. clone ( ) , values. clone ( ) ) ) . collect :: < Vec < _ > > ( ) ;
605-
606603 #[ derive( Serialize ) ]
607604 struct CrateData < ' a > {
608605 doc : String ,
@@ -614,7 +611,8 @@ fn build_index(krate: &clean::Crate, cache: &mut Cache) -> String {
614611 //
615612 // To be noted: the `usize` elements are indexes to `items`.
616613 #[ 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 > > ,
618616 }
619617
620618 // Collect the index into a string
@@ -625,7 +623,7 @@ fn build_index(krate: &clean::Crate, cache: &mut Cache) -> String {
625623 doc: crate_doc,
626624 items: crate_items,
627625 paths: crate_paths,
628- aliases: if crate_aliases . is_empty ( ) { None } else { Some ( crate_aliases ) } ,
626+ aliases,
629627 } )
630628 . expect( "failed serde conversion" )
631629 // All these `replace` calls are because we have to go through JS string for JSON content.
0 commit comments