@@ -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 > {
@@ -951,10 +951,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
951
951
952
952
self . value_cache . clear ( ) ;
953
953
self . value_cache . extend ( targets. iter ( ) . map ( |( value, _) | value) ) ;
954
- let all_len = self . value_cache . len ( ) ;
955
- self . value_cache . sort_unstable ( ) ;
956
- self . value_cache . dedup ( ) ;
957
- let has_duplicates = all_len != self . value_cache . len ( ) ;
954
+ let has_duplicates = targets. iter ( ) . len ( ) != self . value_cache . len ( ) ;
958
955
if has_duplicates {
959
956
self . fail (
960
957
location,
@@ -987,16 +984,14 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
987
984
// passed by a reference to the callee. Consequently they must be non-overlapping.
988
985
// Currently this simply checks for duplicate places.
989
986
self . place_cache . clear ( ) ;
990
- self . place_cache . push ( destination. as_ref ( ) ) ;
987
+ self . place_cache . insert ( destination. as_ref ( ) ) ;
988
+ let mut has_duplicates = false ;
991
989
for arg in args {
992
990
if let Operand :: Move ( place) = arg {
993
- self . place_cache . push ( place. as_ref ( ) ) ;
991
+ has_duplicates |= ! self . place_cache . insert ( place. as_ref ( ) ) ;
994
992
}
995
993
}
996
- let all_len = self . place_cache . len ( ) ;
997
- let mut dedup = FxHashSet :: default ( ) ;
998
- self . place_cache . retain ( |p| dedup. insert ( * p) ) ;
999
- let has_duplicates = all_len != self . place_cache . len ( ) ;
994
+
1000
995
if has_duplicates {
1001
996
self . fail (
1002
997
location,
0 commit comments