Replace FnvHasher use with FxHasher.
This speeds up compilation by 3--6% across most of rustc-benchmarks.
This commit is contained in:
parent
eca1cc957f
commit
00e48affde
91 changed files with 588 additions and 588 deletions
|
|
@ -19,7 +19,7 @@ use rustc::hir::def::{Def, CtorKind};
|
|||
use rustc::hir::def_id::DefId;
|
||||
use rustc::hir::print as pprust;
|
||||
use rustc::ty::{self, TyCtxt};
|
||||
use rustc::util::nodemap::FnvHashSet;
|
||||
use rustc::util::nodemap::FxHashSet;
|
||||
|
||||
use rustc_const_eval::lookup_const_by_id;
|
||||
|
||||
|
|
@ -460,7 +460,7 @@ pub fn build_impl<'a, 'tcx>(cx: &DocContext,
|
|||
.into_iter()
|
||||
.map(|meth| meth.name.to_string())
|
||||
.collect()
|
||||
}).unwrap_or(FnvHashSet());
|
||||
}).unwrap_or(FxHashSet());
|
||||
|
||||
ret.push(clean::Item {
|
||||
inner: clean::ImplItem(clean::Impl {
|
||||
|
|
@ -496,7 +496,7 @@ fn build_module<'a, 'tcx>(cx: &DocContext, tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
|||
// If we're reexporting a reexport it may actually reexport something in
|
||||
// two namespaces, so the target may be listed twice. Make sure we only
|
||||
// visit each node at most once.
|
||||
let mut visited = FnvHashSet();
|
||||
let mut visited = FxHashSet();
|
||||
for item in tcx.sess.cstore.item_children(did) {
|
||||
let def_id = item.def.def_id();
|
||||
if tcx.sess.cstore.visibility(def_id) == ty::Visibility::Public {
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ use rustc::hir::print as pprust;
|
|||
use rustc::ty::subst::Substs;
|
||||
use rustc::ty::{self, AdtKind};
|
||||
use rustc::middle::stability;
|
||||
use rustc::util::nodemap::{FnvHashMap, FnvHashSet};
|
||||
use rustc::util::nodemap::{FxHashMap, FxHashSet};
|
||||
|
||||
use rustc::hir;
|
||||
|
||||
|
|
@ -116,7 +116,7 @@ pub struct Crate {
|
|||
pub access_levels: Arc<AccessLevels<DefId>>,
|
||||
// These are later on moved into `CACHEKEY`, leaving the map empty.
|
||||
// Only here so that they can be filtered through the rustdoc passes.
|
||||
pub external_traits: FnvHashMap<DefId, Trait>,
|
||||
pub external_traits: FxHashMap<DefId, Trait>,
|
||||
}
|
||||
|
||||
struct CrateNum(def_id::CrateNum);
|
||||
|
|
@ -993,7 +993,7 @@ impl<'a, 'tcx> Clean<Generics> for (&'a ty::Generics<'tcx>,
|
|||
// Note that associated types also have a sized bound by default, but we
|
||||
// don't actually know the set of associated types right here so that's
|
||||
// handled in cleaning associated types
|
||||
let mut sized_params = FnvHashSet();
|
||||
let mut sized_params = FxHashSet();
|
||||
where_predicates.retain(|pred| {
|
||||
match *pred {
|
||||
WP::BoundPredicate { ty: Generic(ref g), ref bounds } => {
|
||||
|
|
@ -1693,8 +1693,8 @@ impl Clean<Type> for hir::Ty {
|
|||
});
|
||||
if let Some((tcx, &hir::ItemTy(ref ty, ref generics))) = tcx_and_alias {
|
||||
let provided_params = &path.segments.last().unwrap().parameters;
|
||||
let mut ty_substs = FnvHashMap();
|
||||
let mut lt_substs = FnvHashMap();
|
||||
let mut ty_substs = FxHashMap();
|
||||
let mut lt_substs = FxHashMap();
|
||||
for (i, ty_param) in generics.ty_params.iter().enumerate() {
|
||||
let ty_param_def = tcx.expect_def(ty_param.id);
|
||||
if let Some(ty) = provided_params.types().get(i).cloned()
|
||||
|
|
@ -2368,7 +2368,7 @@ impl Clean<ImplPolarity> for hir::ImplPolarity {
|
|||
pub struct Impl {
|
||||
pub unsafety: hir::Unsafety,
|
||||
pub generics: Generics,
|
||||
pub provided_trait_methods: FnvHashSet<String>,
|
||||
pub provided_trait_methods: FxHashSet<String>,
|
||||
pub trait_: Option<Type>,
|
||||
pub for_: Type,
|
||||
pub items: Vec<Item>,
|
||||
|
|
@ -2394,7 +2394,7 @@ impl Clean<Vec<Item>> for doctree::Impl {
|
|||
.map(|meth| meth.name.to_string())
|
||||
.collect()
|
||||
})
|
||||
}).unwrap_or(FnvHashSet());
|
||||
}).unwrap_or(FxHashSet());
|
||||
|
||||
ret.push(Item {
|
||||
name: None,
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ use rustc::middle::privacy::AccessLevels;
|
|||
use rustc::ty::{self, TyCtxt};
|
||||
use rustc::hir::map as hir_map;
|
||||
use rustc::lint;
|
||||
use rustc::util::nodemap::FnvHashMap;
|
||||
use rustc::util::nodemap::FxHashMap;
|
||||
use rustc_trans::back::link;
|
||||
use rustc_resolve as resolve;
|
||||
use rustc_metadata::cstore::CStore;
|
||||
|
|
@ -48,7 +48,7 @@ pub enum MaybeTyped<'a, 'tcx: 'a> {
|
|||
NotTyped(&'a session::Session)
|
||||
}
|
||||
|
||||
pub type ExternalPaths = FnvHashMap<DefId, (Vec<String>, clean::TypeKind)>;
|
||||
pub type ExternalPaths = FxHashMap<DefId, (Vec<String>, clean::TypeKind)>;
|
||||
|
||||
pub struct DocContext<'a, 'tcx: 'a> {
|
||||
pub map: &'a hir_map::Map<'tcx>,
|
||||
|
|
@ -65,15 +65,15 @@ pub struct DocContext<'a, 'tcx: 'a> {
|
|||
/// Later on moved into `html::render::CACHE_KEY`
|
||||
pub renderinfo: RefCell<RenderInfo>,
|
||||
/// Later on moved through `clean::Crate` into `html::render::CACHE_KEY`
|
||||
pub external_traits: RefCell<FnvHashMap<DefId, clean::Trait>>,
|
||||
pub external_traits: RefCell<FxHashMap<DefId, clean::Trait>>,
|
||||
|
||||
// The current set of type and lifetime substitutions,
|
||||
// for expanding type aliases at the HIR level:
|
||||
|
||||
/// Table type parameter definition -> substituted type
|
||||
pub ty_substs: RefCell<FnvHashMap<Def, clean::Type>>,
|
||||
pub ty_substs: RefCell<FxHashMap<Def, clean::Type>>,
|
||||
/// Table node id of lifetime parameter definition -> substituted lifetime
|
||||
pub lt_substs: RefCell<FnvHashMap<ast::NodeId, clean::Lifetime>>,
|
||||
pub lt_substs: RefCell<FxHashMap<ast::NodeId, clean::Lifetime>>,
|
||||
}
|
||||
|
||||
impl<'b, 'tcx> DocContext<'b, 'tcx> {
|
||||
|
|
@ -99,8 +99,8 @@ impl<'b, 'tcx> DocContext<'b, 'tcx> {
|
|||
/// Call the closure with the given parameters set as
|
||||
/// the substitutions for a type alias' RHS.
|
||||
pub fn enter_alias<F, R>(&self,
|
||||
ty_substs: FnvHashMap<Def, clean::Type>,
|
||||
lt_substs: FnvHashMap<ast::NodeId, clean::Lifetime>,
|
||||
ty_substs: FxHashMap<Def, clean::Type>,
|
||||
lt_substs: FxHashMap<ast::NodeId, clean::Lifetime>,
|
||||
f: F) -> R
|
||||
where F: FnOnce() -> R {
|
||||
let (old_tys, old_lts) =
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ use rustc::hir::def_id::{CrateNum, CRATE_DEF_INDEX, DefId, LOCAL_CRATE};
|
|||
use rustc::middle::privacy::AccessLevels;
|
||||
use rustc::middle::stability;
|
||||
use rustc::hir;
|
||||
use rustc::util::nodemap::{FnvHashMap, FnvHashSet};
|
||||
use rustc::util::nodemap::{FxHashMap, FxHashSet};
|
||||
use rustc_data_structures::flock;
|
||||
|
||||
use clean::{self, Attributes, GetDefId, SelfTy, Mutability};
|
||||
|
|
@ -111,9 +111,9 @@ pub struct SharedContext {
|
|||
/// `true`.
|
||||
pub include_sources: bool,
|
||||
/// The local file sources we've emitted and their respective url-paths.
|
||||
pub local_sources: FnvHashMap<PathBuf, String>,
|
||||
pub local_sources: FxHashMap<PathBuf, String>,
|
||||
/// All the passes that were run on this crate.
|
||||
pub passes: FnvHashSet<String>,
|
||||
pub passes: FxHashSet<String>,
|
||||
/// The base-URL of the issue tracker for when an item has been tagged with
|
||||
/// an issue number.
|
||||
pub issue_tracker_base_url: Option<String>,
|
||||
|
|
@ -208,7 +208,7 @@ pub struct Cache {
|
|||
/// Mapping of typaram ids to the name of the type parameter. This is used
|
||||
/// when pretty-printing a type (so pretty printing doesn't have to
|
||||
/// painfully maintain a context like this)
|
||||
pub typarams: FnvHashMap<DefId, String>,
|
||||
pub typarams: FxHashMap<DefId, String>,
|
||||
|
||||
/// Maps a type id to all known implementations for that type. This is only
|
||||
/// recognized for intra-crate `ResolvedPath` types, and is used to print
|
||||
|
|
@ -216,35 +216,35 @@ pub struct Cache {
|
|||
///
|
||||
/// The values of the map are a list of implementations and documentation
|
||||
/// found on that implementation.
|
||||
pub impls: FnvHashMap<DefId, Vec<Impl>>,
|
||||
pub impls: FxHashMap<DefId, Vec<Impl>>,
|
||||
|
||||
/// Maintains a mapping of local crate node ids to the fully qualified name
|
||||
/// and "short type description" of that node. This is used when generating
|
||||
/// URLs when a type is being linked to. External paths are not located in
|
||||
/// this map because the `External` type itself has all the information
|
||||
/// necessary.
|
||||
pub paths: FnvHashMap<DefId, (Vec<String>, ItemType)>,
|
||||
pub paths: FxHashMap<DefId, (Vec<String>, ItemType)>,
|
||||
|
||||
/// Similar to `paths`, but only holds external paths. This is only used for
|
||||
/// generating explicit hyperlinks to other crates.
|
||||
pub external_paths: FnvHashMap<DefId, (Vec<String>, ItemType)>,
|
||||
pub external_paths: FxHashMap<DefId, (Vec<String>, ItemType)>,
|
||||
|
||||
/// This map contains information about all known traits of this crate.
|
||||
/// Implementations of a crate should inherit the documentation of the
|
||||
/// parent trait if no extra documentation is specified, and default methods
|
||||
/// should show up in documentation about trait implementations.
|
||||
pub traits: FnvHashMap<DefId, clean::Trait>,
|
||||
pub traits: FxHashMap<DefId, clean::Trait>,
|
||||
|
||||
/// When rendering traits, it's often useful to be able to list all
|
||||
/// implementors of the trait, and this mapping is exactly, that: a mapping
|
||||
/// of trait ids to the list of known implementors of the trait
|
||||
pub implementors: FnvHashMap<DefId, Vec<Implementor>>,
|
||||
pub implementors: FxHashMap<DefId, Vec<Implementor>>,
|
||||
|
||||
/// Cache of where external crate documentation can be found.
|
||||
pub extern_locations: FnvHashMap<CrateNum, (String, ExternalLocation)>,
|
||||
pub extern_locations: FxHashMap<CrateNum, (String, ExternalLocation)>,
|
||||
|
||||
/// Cache of where documentation for primitives can be found.
|
||||
pub primitive_locations: FnvHashMap<clean::PrimitiveType, CrateNum>,
|
||||
pub primitive_locations: FxHashMap<clean::PrimitiveType, CrateNum>,
|
||||
|
||||
// Note that external items for which `doc(hidden)` applies to are shown as
|
||||
// non-reachable while local items aren't. This is because we're reusing
|
||||
|
|
@ -257,7 +257,7 @@ pub struct Cache {
|
|||
parent_stack: Vec<DefId>,
|
||||
parent_is_trait_impl: bool,
|
||||
search_index: Vec<IndexItem>,
|
||||
seen_modules: FnvHashSet<DefId>,
|
||||
seen_modules: FxHashSet<DefId>,
|
||||
seen_mod: bool,
|
||||
stripped_mod: bool,
|
||||
deref_trait_did: Option<DefId>,
|
||||
|
|
@ -275,9 +275,9 @@ pub struct Cache {
|
|||
/// Later on moved into `CACHE_KEY`.
|
||||
#[derive(Default)]
|
||||
pub struct RenderInfo {
|
||||
pub inlined: FnvHashSet<DefId>,
|
||||
pub inlined: FxHashSet<DefId>,
|
||||
pub external_paths: ::core::ExternalPaths,
|
||||
pub external_typarams: FnvHashMap<DefId, String>,
|
||||
pub external_typarams: FxHashMap<DefId, String>,
|
||||
pub deref_trait_did: Option<DefId>,
|
||||
pub deref_mut_trait_did: Option<DefId>,
|
||||
}
|
||||
|
|
@ -376,10 +376,10 @@ impl ToJson for IndexItemFunctionType {
|
|||
thread_local!(static CACHE_KEY: RefCell<Arc<Cache>> = Default::default());
|
||||
thread_local!(pub static CURRENT_LOCATION_KEY: RefCell<Vec<String>> =
|
||||
RefCell::new(Vec::new()));
|
||||
thread_local!(static USED_ID_MAP: RefCell<FnvHashMap<String, usize>> =
|
||||
thread_local!(static USED_ID_MAP: RefCell<FxHashMap<String, usize>> =
|
||||
RefCell::new(init_ids()));
|
||||
|
||||
fn init_ids() -> FnvHashMap<String, usize> {
|
||||
fn init_ids() -> FxHashMap<String, usize> {
|
||||
[
|
||||
"main",
|
||||
"search",
|
||||
|
|
@ -406,7 +406,7 @@ pub fn reset_ids(embedded: bool) {
|
|||
*s.borrow_mut() = if embedded {
|
||||
init_ids()
|
||||
} else {
|
||||
FnvHashMap()
|
||||
FxHashMap()
|
||||
};
|
||||
});
|
||||
}
|
||||
|
|
@ -431,7 +431,7 @@ pub fn derive_id(candidate: String) -> String {
|
|||
pub fn run(mut krate: clean::Crate,
|
||||
external_html: &ExternalHtml,
|
||||
dst: PathBuf,
|
||||
passes: FnvHashSet<String>,
|
||||
passes: FxHashSet<String>,
|
||||
css_file_extension: Option<PathBuf>,
|
||||
renderinfo: RenderInfo) -> Result<(), Error> {
|
||||
let src_root = match krate.src.parent() {
|
||||
|
|
@ -442,7 +442,7 @@ pub fn run(mut krate: clean::Crate,
|
|||
src_root: src_root,
|
||||
passes: passes,
|
||||
include_sources: true,
|
||||
local_sources: FnvHashMap(),
|
||||
local_sources: FxHashMap(),
|
||||
issue_tracker_base_url: None,
|
||||
layout: layout::Layout {
|
||||
logo: "".to_string(),
|
||||
|
|
@ -510,22 +510,22 @@ pub fn run(mut krate: clean::Crate,
|
|||
.collect();
|
||||
|
||||
let mut cache = Cache {
|
||||
impls: FnvHashMap(),
|
||||
impls: FxHashMap(),
|
||||
external_paths: external_paths,
|
||||
paths: FnvHashMap(),
|
||||
implementors: FnvHashMap(),
|
||||
paths: FxHashMap(),
|
||||
implementors: FxHashMap(),
|
||||
stack: Vec::new(),
|
||||
parent_stack: Vec::new(),
|
||||
search_index: Vec::new(),
|
||||
parent_is_trait_impl: false,
|
||||
extern_locations: FnvHashMap(),
|
||||
primitive_locations: FnvHashMap(),
|
||||
seen_modules: FnvHashSet(),
|
||||
extern_locations: FxHashMap(),
|
||||
primitive_locations: FxHashMap(),
|
||||
seen_modules: FxHashSet(),
|
||||
seen_mod: false,
|
||||
stripped_mod: false,
|
||||
access_levels: krate.access_levels.clone(),
|
||||
orphan_impl_items: Vec::new(),
|
||||
traits: mem::replace(&mut krate.external_traits, FnvHashMap()),
|
||||
traits: mem::replace(&mut krate.external_traits, FxHashMap()),
|
||||
deref_trait_did: deref_trait_did,
|
||||
deref_mut_trait_did: deref_mut_trait_did,
|
||||
typarams: external_typarams,
|
||||
|
|
@ -572,7 +572,7 @@ pub fn run(mut krate: clean::Crate,
|
|||
|
||||
/// Build the search index from the collected metadata
|
||||
fn build_index(krate: &clean::Crate, cache: &mut Cache) -> String {
|
||||
let mut nodeid_to_pathid = FnvHashMap();
|
||||
let mut nodeid_to_pathid = FxHashMap();
|
||||
let mut crate_items = Vec::with_capacity(cache.search_index.len());
|
||||
let mut crate_paths = Vec::<Json>::new();
|
||||
|
||||
|
|
@ -2618,7 +2618,7 @@ fn render_union(w: &mut fmt::Formatter, it: &clean::Item,
|
|||
#[derive(Copy, Clone)]
|
||||
enum AssocItemLink<'a> {
|
||||
Anchor(Option<&'a str>),
|
||||
GotoSource(DefId, &'a FnvHashSet<String>),
|
||||
GotoSource(DefId, &'a FxHashSet<String>),
|
||||
}
|
||||
|
||||
impl<'a> AssocItemLink<'a> {
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ use rustc::hir::map as hir_map;
|
|||
use rustc::hir::def::Def;
|
||||
use rustc::hir::def_id::LOCAL_CRATE;
|
||||
use rustc::middle::privacy::AccessLevel;
|
||||
use rustc::util::nodemap::FnvHashSet;
|
||||
use rustc::util::nodemap::FxHashSet;
|
||||
|
||||
use rustc::hir;
|
||||
|
||||
|
|
@ -42,14 +42,14 @@ pub struct RustdocVisitor<'a, 'tcx: 'a> {
|
|||
pub module: Module,
|
||||
pub attrs: hir::HirVec<ast::Attribute>,
|
||||
pub cx: &'a core::DocContext<'a, 'tcx>,
|
||||
view_item_stack: FnvHashSet<ast::NodeId>,
|
||||
view_item_stack: FxHashSet<ast::NodeId>,
|
||||
inlining_from_glob: bool,
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
|
||||
pub fn new(cx: &'a core::DocContext<'a, 'tcx>) -> RustdocVisitor<'a, 'tcx> {
|
||||
// If the root is reexported, terminate all recursion.
|
||||
let mut stack = FnvHashSet();
|
||||
let mut stack = FxHashSet();
|
||||
stack.insert(ast::CRATE_NODE_ID);
|
||||
RustdocVisitor {
|
||||
module: Module::new(None),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue