use rustc::ty::subst::Substs;
use rustc::ty;
use rustc::middle::stability;
+use rustc::util::nodemap::{FnvHashMap, FnvHashSet};
use rustc::hir;
-use std::collections::{HashMap, HashSet};
use std::path::PathBuf;
use std::rc::Rc;
use std::sync::Arc;
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: HashMap<DefId, Trait>,
+ pub external_traits: FnvHashMap<DefId, Trait>,
}
struct CrateNum(ast::CrateNum);
// 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 = HashSet::new();
+ let mut sized_params = FnvHashSet();
where_predicates.retain(|pred| {
match *pred {
WP::BoundPredicate { ty: Generic(ref g), ref bounds } => {
struct SubstAlias<'a, 'tcx: 'a> {
tcx: &'a ty::TyCtxt<'a, 'tcx, 'tcx>,
// Table type parameter definition -> substituted type
- ty_substs: HashMap<Def, hir::Ty>,
+ ty_substs: FnvHashMap<Def, hir::Ty>,
// Table node id of lifetime parameter definition -> substituted lifetime
- lt_substs: HashMap<ast::NodeId, hir::Lifetime>,
+ lt_substs: FnvHashMap<ast::NodeId, hir::Lifetime>,
}
impl<'a, 'tcx: 'a, 'b: 'tcx> Folder for SubstAlias<'a, 'tcx> {
let item = tcx.map.expect_item(node_id);
if let hir::ItemTy(ref ty, ref generics) = item.node {
let provided_params = &path.segments.last().unwrap().parameters;
- let mut ty_substs = HashMap::new();
- let mut lt_substs = HashMap::new();
+ let mut ty_substs = FnvHashMap();
+ let mut lt_substs = FnvHashMap();
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()
pub struct Impl {
pub unsafety: hir::Unsafety,
pub generics: Generics,
- pub provided_trait_methods: HashSet<String>,
+ pub provided_trait_methods: FnvHashSet<String>,
pub trait_: Option<Type>,
pub for_: Type,
pub items: Vec<Item>,
.map(|meth| meth.name.to_string())
.collect()
})
- }).unwrap_or(HashSet::new());
+ }).unwrap_or(FnvHashSet());
ret.push(Item {
name: None,
use rustc::ty::{self, TyCtxt};
use rustc::hir::map as hir_map;
use rustc::lint;
+use rustc::util::nodemap::{FnvHashMap, FnvHashSet};
use rustc_trans::back::link;
use rustc_resolve as resolve;
use rustc_metadata::cstore::CStore;
use errors::emitter::ColorConfig;
use std::cell::{RefCell, Cell};
-use std::collections::{HashMap, HashSet};
use std::rc::Rc;
use visit_ast::RustdocVisitor;
NotTyped(&'a session::Session)
}
-pub type ExternalPaths = HashMap<DefId, (Vec<String>, clean::TypeKind)>;
+pub type ExternalPaths = FnvHashMap<DefId, (Vec<String>, clean::TypeKind)>;
pub struct DocContext<'a, 'tcx: 'a> {
pub map: &'a hir_map::Map<'tcx>,
pub maybe_typed: MaybeTyped<'a, 'tcx>,
pub input: Input,
- pub populated_crate_impls: RefCell<HashSet<ast::CrateNum>>,
+ pub populated_crate_impls: RefCell<FnvHashSet<ast::CrateNum>>,
pub deref_trait_did: Cell<Option<DefId>>,
// 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
/// 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<HashMap<DefId, clean::Trait>>,
+ pub external_traits: RefCell<FnvHashMap<DefId, clean::Trait>>,
}
impl<'b, 'tcx> DocContext<'b, 'tcx> {
map: &tcx.map,
maybe_typed: Typed(tcx),
input: input,
- populated_crate_impls: RefCell::new(HashSet::new()),
+ populated_crate_impls: RefCell::new(FnvHashSet()),
deref_trait_did: Cell::new(None),
access_levels: RefCell::new(access_levels),
- external_traits: RefCell::new(HashMap::new()),
+ external_traits: RefCell::new(FnvHashMap()),
renderinfo: RefCell::new(Default::default()),
};
debug!("crate: {:?}", ctxt.map.krate());
use std::ascii::AsciiExt;
use std::cell::RefCell;
use std::cmp::Ordering;
-use std::collections::{BTreeMap, HashMap, HashSet};
+use std::collections::BTreeMap;
use std::default::Default;
use std::error;
use std::fmt::{self, Display, Formatter};
use rustc::middle::stability;
use rustc::session::config::get_unstable_features_setting;
use rustc::hir;
+use rustc::util::nodemap::{FnvHashMap, FnvHashSet};
use clean::{self, Attributes, GetDefId};
use doctree;
/// `true`.
pub include_sources: bool,
/// The local file sources we've emitted and their respective url-paths.
- pub local_sources: HashMap<PathBuf, String>,
+ pub local_sources: FnvHashMap<PathBuf, String>,
/// All the passes that were run on this crate.
- pub passes: HashSet<String>,
+ pub passes: FnvHashSet<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>,
/// 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: HashMap<DefId, String>,
+ pub typarams: FnvHashMap<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
///
/// The values of the map are a list of implementations and documentation
/// found on that implementation.
- pub impls: HashMap<DefId, Vec<Impl>>,
+ pub impls: FnvHashMap<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: HashMap<DefId, (Vec<String>, ItemType)>,
+ pub paths: FnvHashMap<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: HashMap<DefId, (Vec<String>, ItemType)>,
+ pub external_paths: FnvHashMap<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: HashMap<DefId, clean::Trait>,
+ pub traits: FnvHashMap<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: HashMap<DefId, Vec<Implementor>>,
+ pub implementors: FnvHashMap<DefId, Vec<Implementor>>,
/// Cache of where external crate documentation can be found.
- pub extern_locations: HashMap<ast::CrateNum, (String, ExternalLocation)>,
+ pub extern_locations: FnvHashMap<ast::CrateNum, (String, ExternalLocation)>,
/// Cache of where documentation for primitives can be found.
- pub primitive_locations: HashMap<clean::PrimitiveType, ast::CrateNum>,
+ pub primitive_locations: FnvHashMap<clean::PrimitiveType, ast::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
parent_stack: Vec<DefId>,
parent_is_trait_impl: bool,
search_index: Vec<IndexItem>,
- seen_modules: HashSet<DefId>,
+ seen_modules: FnvHashSet<DefId>,
seen_mod: bool,
stripped_mod: bool,
deref_trait_did: Option<DefId>,
/// Later on moved into `CACHE_KEY`.
#[derive(Default)]
pub struct RenderInfo {
- pub inlined: HashSet<DefId>,
+ pub inlined: FnvHashSet<DefId>,
pub external_paths: ::core::ExternalPaths,
- pub external_typarams: HashMap<DefId, String>,
+ pub external_typarams: FnvHashMap<DefId, String>,
pub deref_trait_did: Option<DefId>,
}
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<HashMap<String, usize>> =
+thread_local!(static USED_ID_MAP: RefCell<FnvHashMap<String, usize>> =
RefCell::new(init_ids()));
-fn init_ids() -> HashMap<String, usize> {
+fn init_ids() -> FnvHashMap<String, usize> {
[
"main",
"search",
*s.borrow_mut() = if embedded {
init_ids()
} else {
- HashMap::new()
+ FnvHashMap()
};
});
}
pub fn run(mut krate: clean::Crate,
external_html: &ExternalHtml,
dst: PathBuf,
- passes: HashSet<String>,
+ passes: FnvHashSet<String>,
css_file_extension: Option<PathBuf>,
renderinfo: RenderInfo) -> Result<(), Error> {
let src_root = match krate.src.parent() {
src_root: src_root,
passes: passes,
include_sources: true,
- local_sources: HashMap::new(),
+ local_sources: FnvHashMap(),
issue_tracker_base_url: None,
layout: layout::Layout {
logo: "".to_string(),
.collect();
let mut cache = Cache {
- impls: HashMap::new(),
+ impls: FnvHashMap(),
external_paths: external_paths,
- paths: HashMap::new(),
- implementors: HashMap::new(),
+ paths: FnvHashMap(),
+ implementors: FnvHashMap(),
stack: Vec::new(),
parent_stack: Vec::new(),
search_index: Vec::new(),
parent_is_trait_impl: false,
- extern_locations: HashMap::new(),
- primitive_locations: HashMap::new(),
- seen_modules: HashSet::new(),
+ extern_locations: FnvHashMap(),
+ primitive_locations: FnvHashMap(),
+ seen_modules: FnvHashSet(),
seen_mod: false,
stripped_mod: false,
access_levels: krate.access_levels.clone(),
orphan_methods: Vec::new(),
- traits: mem::replace(&mut krate.external_traits, HashMap::new()),
+ traits: mem::replace(&mut krate.external_traits, FnvHashMap()),
deref_trait_did: deref_trait_did,
typarams: external_typarams,
};
/// Build the search index from the collected metadata
fn build_index(krate: &clean::Crate, cache: &mut Cache) -> String {
- let mut nodeid_to_pathid = HashMap::new();
+ let mut nodeid_to_pathid = FnvHashMap();
let mut crate_items = Vec::with_capacity(cache.search_index.len());
let mut crate_paths = Vec::<Json>::new();
#[derive(Copy, Clone)]
enum AssocItemLink<'a> {
Anchor(Option<&'a str>),
- GotoSource(DefId, &'a HashSet<String>),
+ GotoSource(DefId, &'a FnvHashSet<String>),
}
impl<'a> AssocItemLink<'a> {