11use crate :: frozen:: Frozen ;
2- use crate :: fx:: FxIndexSet ;
2+ use crate :: fx:: { FxHashSet , FxIndexSet } ;
33use rustc_index:: bit_set:: BitMatrix ;
44use std:: fmt:: Debug ;
55use std:: hash:: Hash ;
@@ -16,7 +16,7 @@ pub struct TransitiveRelationBuilder<T> {
1616
1717 // List of base edges in the graph. Require to compute transitive
1818 // closure.
19- edges : Vec < Edge > ,
19+ edges : FxHashSet < Edge > ,
2020}
2121
2222#[ derive( Debug ) ]
@@ -52,10 +52,10 @@ impl<T: Eq + Hash> Default for TransitiveRelationBuilder<T> {
5252 }
5353}
5454
55- #[ derive( Copy , Clone , PartialEq , Eq , PartialOrd , Debug ) ]
55+ #[ derive( Copy , Clone , PartialEq , Eq , PartialOrd , Debug , Hash ) ]
5656struct Index ( usize ) ;
5757
58- #[ derive( Clone , PartialEq , Eq , Debug ) ]
58+ #[ derive( Clone , PartialEq , Eq , Debug , Hash ) ]
5959struct Edge {
6060 source : Index ,
6161 target : Index ,
@@ -99,9 +99,7 @@ impl<T: Eq + Hash + Copy> TransitiveRelationBuilder<T> {
9999 let a = self . add_index ( a) ;
100100 let b = self . add_index ( b) ;
101101 let edge = Edge { source : a, target : b } ;
102- if !self . edges . contains ( & edge) {
103- self . edges . push ( edge) ;
104- }
102+ self . edges . insert ( edge) ;
105103 }
106104
107105 /// Compute the transitive closure derived from the edges, and converted to
0 commit comments