@@ -67,8 +67,8 @@ impl<'tcx> MirPass<'tcx> for Validator {
67
67
unwind_edge_count : 0 ,
68
68
reachable_blocks : traversal:: reachable_as_bitset ( body) ,
69
69
storage_liveness,
70
- place_cache : Vec :: new ( ) ,
71
- value_cache : Vec :: new ( ) ,
70
+ place_cache : FxHashSet :: default ( ) ,
71
+ value_cache : FxHashSet :: default ( ) ,
72
72
} ;
73
73
checker. visit_body ( body) ;
74
74
checker. check_cleanup_control_flow ( ) ;
@@ -95,8 +95,8 @@ struct TypeChecker<'a, 'tcx> {
95
95
unwind_edge_count : usize ,
96
96
reachable_blocks : BitSet < BasicBlock > ,
97
97
storage_liveness : ResultsCursor < ' a , ' tcx , MaybeStorageLive < ' static > > ,
98
- place_cache : Vec < PlaceRef < ' tcx > > ,
99
- value_cache : Vec < u128 > ,
98
+ place_cache : FxHashSet < PlaceRef < ' tcx > > ,
99
+ value_cache : FxHashSet < u128 > ,
100
100
}
101
101
102
102
impl < ' a , ' tcx > TypeChecker < ' a , ' tcx > {
@@ -958,10 +958,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
958
958
959
959
self . value_cache . clear ( ) ;
960
960
self . value_cache . extend ( targets. iter ( ) . map ( |( value, _) | value) ) ;
961
- let all_len = self . value_cache . len ( ) ;
962
- self . value_cache . sort_unstable ( ) ;
963
- self . value_cache . dedup ( ) ;
964
- let has_duplicates = all_len != self . value_cache . len ( ) ;
961
+ let has_duplicates = targets. iter ( ) . len ( ) != self . value_cache . len ( ) ;
965
962
if has_duplicates {
966
963
self . fail (
967
964
location,
@@ -994,16 +991,14 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
994
991
// passed by a reference to the callee. Consequently they must be non-overlapping.
995
992
// Currently this simply checks for duplicate places.
996
993
self . place_cache . clear ( ) ;
997
- self . place_cache . push ( destination. as_ref ( ) ) ;
994
+ self . place_cache . insert ( destination. as_ref ( ) ) ;
995
+ let mut has_duplicates = false ;
998
996
for arg in args {
999
997
if let Operand :: Move ( place) = arg {
1000
- self . place_cache . push ( place. as_ref ( ) ) ;
998
+ has_duplicates |= ! self . place_cache . insert ( place. as_ref ( ) ) ;
1001
999
}
1002
1000
}
1003
- let all_len = self . place_cache . len ( ) ;
1004
- let mut dedup = FxHashSet :: default ( ) ;
1005
- self . place_cache . retain ( |p| dedup. insert ( * p) ) ;
1006
- let has_duplicates = all_len != self . place_cache . len ( ) ;
1001
+
1007
1002
if has_duplicates {
1008
1003
self . fail (
1009
1004
location,
0 commit comments