1
1
use crate :: frozen:: Frozen ;
2
- use crate :: fx:: FxIndexSet ;
2
+ use crate :: fx:: { FxHashSet , FxIndexSet } ;
3
3
use rustc_index:: bit_set:: BitMatrix ;
4
4
use std:: fmt:: Debug ;
5
5
use std:: hash:: Hash ;
@@ -16,7 +16,7 @@ pub struct TransitiveRelationBuilder<T> {
16
16
17
17
// List of base edges in the graph. Require to compute transitive
18
18
// closure.
19
- edges : Vec < Edge > ,
19
+ edges : FxHashSet < Edge > ,
20
20
}
21
21
22
22
#[ derive( Debug ) ]
@@ -52,10 +52,10 @@ impl<T: Eq + Hash> Default for TransitiveRelationBuilder<T> {
52
52
}
53
53
}
54
54
55
- #[ derive( Copy , Clone , PartialEq , Eq , PartialOrd , Debug ) ]
55
+ #[ derive( Copy , Clone , PartialEq , Eq , PartialOrd , Debug , Hash ) ]
56
56
struct Index ( usize ) ;
57
57
58
- #[ derive( Clone , PartialEq , Eq , Debug ) ]
58
+ #[ derive( Clone , PartialEq , Eq , Debug , Hash ) ]
59
59
struct Edge {
60
60
source : Index ,
61
61
target : Index ,
@@ -99,9 +99,7 @@ impl<T: Eq + Hash + Copy> TransitiveRelationBuilder<T> {
99
99
let a = self . add_index ( a) ;
100
100
let b = self . add_index ( b) ;
101
101
let edge = Edge { source : a, target : b } ;
102
- if !self . edges . contains ( & edge) {
103
- self . edges . push ( edge) ;
104
- }
102
+ self . edges . insert ( edge) ;
105
103
}
106
104
107
105
/// Compute the transitive closure derived from the edges, and converted to
0 commit comments