@@ -37,7 +37,7 @@ pub use self::ExternalLocation::*;
37
37
use std:: ascii:: AsciiExt ;
38
38
use std:: cell:: RefCell ;
39
39
use std:: cmp:: Ordering ;
40
- use std:: collections:: { BTreeMap , HashMap , HashSet } ;
40
+ use std:: collections:: BTreeMap ;
41
41
use std:: default:: Default ;
42
42
use std:: error;
43
43
use std:: fmt:: { self , Display , Formatter } ;
@@ -61,6 +61,7 @@ use rustc::middle::privacy::AccessLevels;
61
61
use rustc:: middle:: stability;
62
62
use rustc:: session:: config:: get_unstable_features_setting;
63
63
use rustc:: hir;
64
+ use rustc:: util:: nodemap:: { FnvHashMap , FnvHashSet } ;
64
65
65
66
use clean:: { self , Attributes , GetDefId } ;
66
67
use doctree;
@@ -114,9 +115,9 @@ pub struct SharedContext {
114
115
/// `true`.
115
116
pub include_sources : bool ,
116
117
/// 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 > ,
118
119
/// All the passes that were run on this crate.
119
- pub passes : HashSet < String > ,
120
+ pub passes : FnvHashSet < String > ,
120
121
/// The base-URL of the issue tracker for when an item has been tagged with
121
122
/// an issue number.
122
123
pub issue_tracker_base_url : Option < String > ,
@@ -211,43 +212,43 @@ pub struct Cache {
211
212
/// Mapping of typaram ids to the name of the type parameter. This is used
212
213
/// when pretty-printing a type (so pretty printing doesn't have to
213
214
/// painfully maintain a context like this)
214
- pub typarams : HashMap < DefId , String > ,
215
+ pub typarams : FnvHashMap < DefId , String > ,
215
216
216
217
/// Maps a type id to all known implementations for that type. This is only
217
218
/// recognized for intra-crate `ResolvedPath` types, and is used to print
218
219
/// out extra documentation on the page of an enum/struct.
219
220
///
220
221
/// The values of the map are a list of implementations and documentation
221
222
/// found on that implementation.
222
- pub impls : HashMap < DefId , Vec < Impl > > ,
223
+ pub impls : FnvHashMap < DefId , Vec < Impl > > ,
223
224
224
225
/// Maintains a mapping of local crate node ids to the fully qualified name
225
226
/// and "short type description" of that node. This is used when generating
226
227
/// URLs when a type is being linked to. External paths are not located in
227
228
/// this map because the `External` type itself has all the information
228
229
/// necessary.
229
- pub paths : HashMap < DefId , ( Vec < String > , ItemType ) > ,
230
+ pub paths : FnvHashMap < DefId , ( Vec < String > , ItemType ) > ,
230
231
231
232
/// Similar to `paths`, but only holds external paths. This is only used for
232
233
/// generating explicit hyperlinks to other crates.
233
- pub external_paths : HashMap < DefId , ( Vec < String > , ItemType ) > ,
234
+ pub external_paths : FnvHashMap < DefId , ( Vec < String > , ItemType ) > ,
234
235
235
236
/// This map contains information about all known traits of this crate.
236
237
/// Implementations of a crate should inherit the documentation of the
237
238
/// parent trait if no extra documentation is specified, and default methods
238
239
/// should show up in documentation about trait implementations.
239
- pub traits : HashMap < DefId , clean:: Trait > ,
240
+ pub traits : FnvHashMap < DefId , clean:: Trait > ,
240
241
241
242
/// When rendering traits, it's often useful to be able to list all
242
243
/// implementors of the trait, and this mapping is exactly, that: a mapping
243
244
/// 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 > > ,
245
246
246
247
/// 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 ) > ,
248
249
249
250
/// 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 > ,
251
252
252
253
// Note that external items for which `doc(hidden)` applies to are shown as
253
254
// non-reachable while local items aren't. This is because we're reusing
@@ -260,7 +261,7 @@ pub struct Cache {
260
261
parent_stack : Vec < DefId > ,
261
262
parent_is_trait_impl : bool ,
262
263
search_index : Vec < IndexItem > ,
263
- seen_modules : HashSet < DefId > ,
264
+ seen_modules : FnvHashSet < DefId > ,
264
265
seen_mod : bool ,
265
266
stripped_mod : bool ,
266
267
deref_trait_did : Option < DefId > ,
@@ -277,9 +278,9 @@ pub struct Cache {
277
278
/// Later on moved into `CACHE_KEY`.
278
279
#[ derive( Default ) ]
279
280
pub struct RenderInfo {
280
- pub inlined : HashSet < DefId > ,
281
+ pub inlined : FnvHashSet < DefId > ,
281
282
pub external_paths : :: core:: ExternalPaths ,
282
- pub external_typarams : HashMap < DefId , String > ,
283
+ pub external_typarams : FnvHashMap < DefId , String > ,
283
284
pub deref_trait_did : Option < DefId > ,
284
285
}
285
286
@@ -377,10 +378,10 @@ impl ToJson for IndexItemFunctionType {
377
378
thread_local ! ( static CACHE_KEY : RefCell <Arc <Cache >> = Default :: default ( ) ) ;
378
379
thread_local ! ( pub static CURRENT_LOCATION_KEY : RefCell <Vec <String >> =
379
380
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 >> =
381
382
RefCell :: new( init_ids( ) ) ) ;
382
383
383
- fn init_ids ( ) -> HashMap < String , usize > {
384
+ fn init_ids ( ) -> FnvHashMap < String , usize > {
384
385
[
385
386
"main" ,
386
387
"search" ,
@@ -407,7 +408,7 @@ pub fn reset_ids(embedded: bool) {
407
408
* s. borrow_mut ( ) = if embedded {
408
409
init_ids ( )
409
410
} else {
410
- HashMap :: new ( )
411
+ FnvHashMap ( )
411
412
} ;
412
413
} ) ;
413
414
}
@@ -432,7 +433,7 @@ pub fn derive_id(candidate: String) -> String {
432
433
pub fn run ( mut krate : clean:: Crate ,
433
434
external_html : & ExternalHtml ,
434
435
dst : PathBuf ,
435
- passes : HashSet < String > ,
436
+ passes : FnvHashSet < String > ,
436
437
css_file_extension : Option < PathBuf > ,
437
438
renderinfo : RenderInfo ) -> Result < ( ) , Error > {
438
439
let src_root = match krate. src . parent ( ) {
@@ -443,7 +444,7 @@ pub fn run(mut krate: clean::Crate,
443
444
src_root : src_root,
444
445
passes : passes,
445
446
include_sources : true ,
446
- local_sources : HashMap :: new ( ) ,
447
+ local_sources : FnvHashMap ( ) ,
447
448
issue_tracker_base_url : None ,
448
449
layout : layout:: Layout {
449
450
logo : "" . to_string ( ) ,
@@ -513,22 +514,22 @@ pub fn run(mut krate: clean::Crate,
513
514
. collect ( ) ;
514
515
515
516
let mut cache = Cache {
516
- impls : HashMap :: new ( ) ,
517
+ impls : FnvHashMap ( ) ,
517
518
external_paths : external_paths,
518
- paths : HashMap :: new ( ) ,
519
- implementors : HashMap :: new ( ) ,
519
+ paths : FnvHashMap ( ) ,
520
+ implementors : FnvHashMap ( ) ,
520
521
stack : Vec :: new ( ) ,
521
522
parent_stack : Vec :: new ( ) ,
522
523
search_index : Vec :: new ( ) ,
523
524
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 ( ) ,
527
528
seen_mod : false ,
528
529
stripped_mod : false ,
529
530
access_levels : krate. access_levels . clone ( ) ,
530
531
orphan_methods : Vec :: new ( ) ,
531
- traits : mem:: replace ( & mut krate. external_traits , HashMap :: new ( ) ) ,
532
+ traits : mem:: replace ( & mut krate. external_traits , FnvHashMap ( ) ) ,
532
533
deref_trait_did : deref_trait_did,
533
534
typarams : external_typarams,
534
535
} ;
@@ -574,7 +575,7 @@ pub fn run(mut krate: clean::Crate,
574
575
575
576
/// Build the search index from the collected metadata
576
577
fn build_index ( krate : & clean:: Crate , cache : & mut Cache ) -> String {
577
- let mut nodeid_to_pathid = HashMap :: new ( ) ;
578
+ let mut nodeid_to_pathid = FnvHashMap ( ) ;
578
579
let mut crate_items = Vec :: with_capacity ( cache. search_index . len ( ) ) ;
579
580
let mut crate_paths = Vec :: < Json > :: new ( ) ;
580
581
@@ -2515,7 +2516,7 @@ fn render_struct(w: &mut fmt::Formatter, it: &clean::Item,
2515
2516
#[ derive( Copy , Clone ) ]
2516
2517
enum AssocItemLink < ' a > {
2517
2518
Anchor ( Option < & ' a str > ) ,
2518
- GotoSource ( DefId , & ' a HashSet < String > ) ,
2519
+ GotoSource ( DefId , & ' a FnvHashSet < String > ) ,
2519
2520
}
2520
2521
2521
2522
impl < ' a > AssocItemLink < ' a > {
0 commit comments