about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAndrew Cann <shum@canndrew.org>2016-11-22 14:39:56 +0800
committerAndrew Cann <shum@canndrew.org>2016-11-22 14:39:56 +0800
commit2afec4dad1e80b3e53256306822f7849b7b9d128 (patch)
tree3f1cb6e0db43c2fc553908fbc7c6ed862b137b03
parentd756f61a5a7ab84d58fdaa9d53d84f6dad29f8db (diff)
downloadrust-2afec4dad1e80b3e53256306822f7849b7b9d128.tar.gz
rust-2afec4dad1e80b3e53256306822f7849b7b9d128.zip
Use FxHashSet instead of HashMap
-rw-r--r--src/librustc/ty/mod.rs14
-rw-r--r--src/librustc/ty/sty.rs6
2 files changed, 9 insertions, 11 deletions
diff --git a/src/librustc/ty/mod.rs b/src/librustc/ty/mod.rs
index 88eb4ec1014..d3864539c75 100644
--- a/src/librustc/ty/mod.rs
+++ b/src/librustc/ty/mod.rs
@@ -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 {
diff --git a/src/librustc/ty/sty.rs b/src/librustc/ty/sty.rs
index 4e54e3a3630..cb3176cce10 100644
--- a/src/librustc/ty/sty.rs
+++ b/src/librustc/ty/sty.rs
@@ -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 {