@@ -37,7 +37,7 @@ pub use self::ExternalLocation::*;
3737use std:: ascii:: AsciiExt ;
3838use std:: cell:: RefCell ;
3939use std:: cmp:: Ordering ;
40- use std:: collections:: { BTreeMap , HashMap , HashSet } ;
40+ use std:: collections:: BTreeMap ;
4141use std:: default:: Default ;
4242use std:: error;
4343use std:: fmt:: { self , Display , Formatter } ;
@@ -61,6 +61,7 @@ use rustc::middle::privacy::AccessLevels;
6161use rustc:: middle:: stability;
6262use rustc:: session:: config:: get_unstable_features_setting;
6363use rustc:: hir;
64+ use rustc:: util:: nodemap:: { FnvHashMap , FnvHashSet } ;
6465
6566use clean:: { self , Attributes , GetDefId } ;
6667use doctree;
@@ -114,9 +115,9 @@ pub struct SharedContext {
114115 /// `true`.
115116 pub include_sources : bool ,
116117 /// The local file sources we've emitted and their respective url-paths.
117- pub local_sources : HashMap < PathBuf , String > ,
118+ pub local_sources : FnvHashMap < PathBuf , String > ,
118119 /// All the passes that were run on this crate.
119- pub passes : HashSet < String > ,
120+ pub passes : FnvHashSet < String > ,
120121 /// The base-URL of the issue tracker for when an item has been tagged with
121122 /// an issue number.
122123 pub issue_tracker_base_url : Option < String > ,
@@ -211,43 +212,43 @@ pub struct Cache {
211212 /// Mapping of typaram ids to the name of the type parameter. This is used
212213 /// when pretty-printing a type (so pretty printing doesn't have to
213214 /// painfully maintain a context like this)
214- pub typarams : HashMap < DefId , String > ,
215+ pub typarams : FnvHashMap < DefId , String > ,
215216
216217 /// Maps a type id to all known implementations for that type. This is only
217218 /// recognized for intra-crate `ResolvedPath` types, and is used to print
218219 /// out extra documentation on the page of an enum/struct.
219220 ///
220221 /// The values of the map are a list of implementations and documentation
221222 /// found on that implementation.
222- pub impls : HashMap < DefId , Vec < Impl > > ,
223+ pub impls : FnvHashMap < DefId , Vec < Impl > > ,
223224
224225 /// Maintains a mapping of local crate node ids to the fully qualified name
225226 /// and "short type description" of that node. This is used when generating
226227 /// URLs when a type is being linked to. External paths are not located in
227228 /// this map because the `External` type itself has all the information
228229 /// necessary.
229- pub paths : HashMap < DefId , ( Vec < String > , ItemType ) > ,
230+ pub paths : FnvHashMap < DefId , ( Vec < String > , ItemType ) > ,
230231
231232 /// Similar to `paths`, but only holds external paths. This is only used for
232233 /// generating explicit hyperlinks to other crates.
233- pub external_paths : HashMap < DefId , ( Vec < String > , ItemType ) > ,
234+ pub external_paths : FnvHashMap < DefId , ( Vec < String > , ItemType ) > ,
234235
235236 /// This map contains information about all known traits of this crate.
236237 /// Implementations of a crate should inherit the documentation of the
237238 /// parent trait if no extra documentation is specified, and default methods
238239 /// should show up in documentation about trait implementations.
239- pub traits : HashMap < DefId , clean:: Trait > ,
240+ pub traits : FnvHashMap < DefId , clean:: Trait > ,
240241
241242 /// When rendering traits, it's often useful to be able to list all
242243 /// implementors of the trait, and this mapping is exactly, that: a mapping
243244 /// of trait ids to the list of known implementors of the trait
244- pub implementors : HashMap < DefId , Vec < Implementor > > ,
245+ pub implementors : FnvHashMap < DefId , Vec < Implementor > > ,
245246
246247 /// Cache of where external crate documentation can be found.
247- pub extern_locations : HashMap < ast:: CrateNum , ( String , ExternalLocation ) > ,
248+ pub extern_locations : FnvHashMap < ast:: CrateNum , ( String , ExternalLocation ) > ,
248249
249250 /// Cache of where documentation for primitives can be found.
250- pub primitive_locations : HashMap < clean:: PrimitiveType , ast:: CrateNum > ,
251+ pub primitive_locations : FnvHashMap < clean:: PrimitiveType , ast:: CrateNum > ,
251252
252253 // Note that external items for which `doc(hidden)` applies to are shown as
253254 // non-reachable while local items aren't. This is because we're reusing
@@ -260,7 +261,7 @@ pub struct Cache {
260261 parent_stack : Vec < DefId > ,
261262 parent_is_trait_impl : bool ,
262263 search_index : Vec < IndexItem > ,
263- seen_modules : HashSet < DefId > ,
264+ seen_modules : FnvHashSet < DefId > ,
264265 seen_mod : bool ,
265266 stripped_mod : bool ,
266267 deref_trait_did : Option < DefId > ,
@@ -277,9 +278,9 @@ pub struct Cache {
277278/// Later on moved into `CACHE_KEY`.
278279#[ derive( Default ) ]
279280pub struct RenderInfo {
280- pub inlined : HashSet < DefId > ,
281+ pub inlined : FnvHashSet < DefId > ,
281282 pub external_paths : :: core:: ExternalPaths ,
282- pub external_typarams : HashMap < DefId , String > ,
283+ pub external_typarams : FnvHashMap < DefId , String > ,
283284 pub deref_trait_did : Option < DefId > ,
284285}
285286
@@ -377,10 +378,10 @@ impl ToJson for IndexItemFunctionType {
377378thread_local ! ( static CACHE_KEY : RefCell <Arc <Cache >> = Default :: default ( ) ) ;
378379thread_local ! ( pub static CURRENT_LOCATION_KEY : RefCell <Vec <String >> =
379380 RefCell :: new( Vec :: new( ) ) ) ;
380- thread_local ! ( static USED_ID_MAP : RefCell <HashMap <String , usize >> =
381+ thread_local ! ( static USED_ID_MAP : RefCell <FnvHashMap <String , usize >> =
381382 RefCell :: new( init_ids( ) ) ) ;
382383
383- fn init_ids ( ) -> HashMap < String , usize > {
384+ fn init_ids ( ) -> FnvHashMap < String , usize > {
384385 [
385386 "main" ,
386387 "search" ,
@@ -407,7 +408,7 @@ pub fn reset_ids(embedded: bool) {
407408 * s. borrow_mut ( ) = if embedded {
408409 init_ids ( )
409410 } else {
410- HashMap :: new ( )
411+ FnvHashMap ( )
411412 } ;
412413 } ) ;
413414}
@@ -432,7 +433,7 @@ pub fn derive_id(candidate: String) -> String {
432433pub fn run ( mut krate : clean:: Crate ,
433434 external_html : & ExternalHtml ,
434435 dst : PathBuf ,
435- passes : HashSet < String > ,
436+ passes : FnvHashSet < String > ,
436437 css_file_extension : Option < PathBuf > ,
437438 renderinfo : RenderInfo ) -> Result < ( ) , Error > {
438439 let src_root = match krate. src . parent ( ) {
@@ -443,7 +444,7 @@ pub fn run(mut krate: clean::Crate,
443444 src_root : src_root,
444445 passes : passes,
445446 include_sources : true ,
446- local_sources : HashMap :: new ( ) ,
447+ local_sources : FnvHashMap ( ) ,
447448 issue_tracker_base_url : None ,
448449 layout : layout:: Layout {
449450 logo : "" . to_string ( ) ,
@@ -513,22 +514,22 @@ pub fn run(mut krate: clean::Crate,
513514 . collect ( ) ;
514515
515516 let mut cache = Cache {
516- impls : HashMap :: new ( ) ,
517+ impls : FnvHashMap ( ) ,
517518 external_paths : external_paths,
518- paths : HashMap :: new ( ) ,
519- implementors : HashMap :: new ( ) ,
519+ paths : FnvHashMap ( ) ,
520+ implementors : FnvHashMap ( ) ,
520521 stack : Vec :: new ( ) ,
521522 parent_stack : Vec :: new ( ) ,
522523 search_index : Vec :: new ( ) ,
523524 parent_is_trait_impl : false ,
524- extern_locations : HashMap :: new ( ) ,
525- primitive_locations : HashMap :: new ( ) ,
526- seen_modules : HashSet :: new ( ) ,
525+ extern_locations : FnvHashMap ( ) ,
526+ primitive_locations : FnvHashMap ( ) ,
527+ seen_modules : FnvHashSet ( ) ,
527528 seen_mod : false ,
528529 stripped_mod : false ,
529530 access_levels : krate. access_levels . clone ( ) ,
530531 orphan_methods : Vec :: new ( ) ,
531- traits : mem:: replace ( & mut krate. external_traits , HashMap :: new ( ) ) ,
532+ traits : mem:: replace ( & mut krate. external_traits , FnvHashMap ( ) ) ,
532533 deref_trait_did : deref_trait_did,
533534 typarams : external_typarams,
534535 } ;
@@ -574,7 +575,7 @@ pub fn run(mut krate: clean::Crate,
574575
575576/// Build the search index from the collected metadata
576577fn build_index ( krate : & clean:: Crate , cache : & mut Cache ) -> String {
577- let mut nodeid_to_pathid = HashMap :: new ( ) ;
578+ let mut nodeid_to_pathid = FnvHashMap ( ) ;
578579 let mut crate_items = Vec :: with_capacity ( cache. search_index . len ( ) ) ;
579580 let mut crate_paths = Vec :: < Json > :: new ( ) ;
580581
@@ -2515,7 +2516,7 @@ fn render_struct(w: &mut fmt::Formatter, it: &clean::Item,
25152516#[ derive( Copy , Clone ) ]
25162517enum AssocItemLink < ' a > {
25172518 Anchor ( Option < & ' a str > ) ,
2518- GotoSource ( DefId , & ' a HashSet < String > ) ,
2519+ GotoSource ( DefId , & ' a FnvHashSet < String > ) ,
25192520}
25202521
25212522impl < ' a > AssocItemLink < ' a > {
0 commit comments