Use FxHashSet instead of HashMap
This commit is contained in:
parent
d756f61a5a
commit
2afec4dad1
2 changed files with 9 additions and 11 deletions
|
|
@ -16,7 +16,6 @@ pub use self::IntVarValue::*;
|
|||
pub use self::LvaluePreference::*;
|
||||
pub use self::fold::TypeFoldable;
|
||||
|
||||
use std::collections::{hash_map, HashMap};
|
||||
use dep_graph::{self, DepNode};
|
||||
use hir::map as ast_map;
|
||||
use middle;
|
||||
|
|
@ -31,7 +30,7 @@ use ty::subst::{Subst, Substs};
|
|||
use ty::walk::TypeWalker;
|
||||
use util::common::MemoizationMap;
|
||||
use util::nodemap::NodeSet;
|
||||
use util::nodemap::FxHashMap;
|
||||
use util::nodemap::{FxHashMap, FxHashSet};
|
||||
|
||||
use serialize::{self, Encodable, Encoder};
|
||||
use std::borrow::Cow;
|
||||
|
|
@ -1393,13 +1392,12 @@ impl<'tcx> serialize::UseSpecializedDecodable for AdtDef<'tcx> {}
|
|||
impl<'a, 'gcx, 'tcx> AdtDefData<'tcx, 'static> {
|
||||
#[inline]
|
||||
pub fn is_uninhabited_recurse(&'tcx self,
|
||||
visited: &mut HashMap<(DefId, &'tcx Substs<'tcx>), ()>,
|
||||
visited: &mut FxHashSet<(DefId, &'tcx Substs<'tcx>)>,
|
||||
block: Option<NodeId>,
|
||||
cx: TyCtxt<'a, 'gcx, 'tcx>,
|
||||
substs: &'tcx Substs<'tcx>) -> bool {
|
||||
match visited.entry((self.did, substs)) {
|
||||
hash_map::Entry::Occupied(_) => return false,
|
||||
hash_map::Entry::Vacant(ve) => ve.insert(()),
|
||||
if !visited.insert((self.did, substs)) {
|
||||
return false;
|
||||
};
|
||||
self.variants.iter().all(|v| {
|
||||
v.is_uninhabited_recurse(visited, block, cx, substs, self.is_union())
|
||||
|
|
@ -1811,7 +1809,7 @@ impl<'tcx, 'container> VariantDefData<'tcx, 'container> {
|
|||
impl<'a, 'gcx, 'tcx> VariantDefData<'tcx, 'static> {
|
||||
#[inline]
|
||||
pub fn is_uninhabited_recurse(&'tcx self,
|
||||
visited: &mut HashMap<(DefId, &'tcx Substs<'tcx>), ()>,
|
||||
visited: &mut FxHashSet<(DefId, &'tcx Substs<'tcx>)>,
|
||||
block: Option<NodeId>,
|
||||
cx: TyCtxt<'a, 'gcx, 'tcx>,
|
||||
substs: &'tcx Substs<'tcx>,
|
||||
|
|
@ -1852,7 +1850,7 @@ impl<'a, 'gcx, 'tcx, 'container> FieldDefData<'tcx, 'container> {
|
|||
impl<'a, 'gcx, 'tcx> FieldDefData<'tcx, 'static> {
|
||||
#[inline]
|
||||
pub fn is_uninhabited_recurse(&'tcx self,
|
||||
visited: &mut HashMap<(DefId, &'tcx Substs<'tcx>), ()>,
|
||||
visited: &mut FxHashSet<(DefId, &'tcx Substs<'tcx>)>,
|
||||
block: Option<NodeId>,
|
||||
tcx: TyCtxt<'a, 'gcx, 'tcx>,
|
||||
substs: &'tcx Substs<'tcx>) -> bool {
|
||||
|
|
|
|||
|
|
@ -21,10 +21,10 @@ use util::common::ErrorReported;
|
|||
use collections::enum_set::{self, EnumSet, CLike};
|
||||
use std::fmt;
|
||||
use std::ops;
|
||||
use std::collections::HashMap;
|
||||
use syntax::abi;
|
||||
use syntax::ast::{self, Name, NodeId};
|
||||
use syntax::symbol::{keywords, InternedString};
|
||||
use util::nodemap::FxHashSet;
|
||||
|
||||
use serialize;
|
||||
|
||||
|
|
@ -933,12 +933,12 @@ impl<'a, 'gcx, 'tcx> TyS<'tcx> {
|
|||
/// Checks whether a type is uninhabited.
|
||||
/// If `block` is `Some(id)` it also checks that the uninhabited-ness is visible from `id`.
|
||||
pub fn is_uninhabited(&self, block: Option<NodeId>, cx: TyCtxt<'a, 'gcx, 'tcx>) -> bool {
|
||||
let mut visited = HashMap::new();
|
||||
let mut visited = FxHashSet::default();
|
||||
self.is_uninhabited_recurse(&mut visited, block, cx)
|
||||
}
|
||||
|
||||
pub fn is_uninhabited_recurse(&self,
|
||||
visited: &mut HashMap<(DefId, &'tcx Substs<'tcx>), ()>,
|
||||
visited: &mut FxHashSet<(DefId, &'tcx Substs<'tcx>)>,
|
||||
block: Option<NodeId>,
|
||||
cx: TyCtxt<'a, 'gcx, 'tcx>) -> bool {
|
||||
match self.sty {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue