11
11
use middle:: subst:: { Substs , VecPerParamSpace } ;
12
12
use middle:: infer:: InferCtxt ;
13
13
use middle:: ty:: { self , Ty , AsPredicate , ToPolyTraitRef } ;
14
- use std:: collections:: HashSet ;
15
14
use std:: fmt;
16
15
use std:: rc:: Rc ;
17
16
use syntax:: ast;
18
17
use syntax:: codemap:: Span ;
19
18
use util:: common:: ErrorReported ;
19
+ use util:: nodemap:: FnvHashSet ;
20
20
use util:: ppaux:: Repr ;
21
21
22
22
use super :: { Obligation , ObligationCause , PredicateObligation ,
@@ -36,7 +36,7 @@ use super::{Obligation, ObligationCause, PredicateObligation,
36
36
pub struct Elaborator < ' cx , ' tcx : ' cx > {
37
37
tcx : & ' cx ty:: ctxt < ' tcx > ,
38
38
stack : Vec < StackEntry < ' tcx > > ,
39
- visited : HashSet < ty:: Predicate < ' tcx > > ,
39
+ visited : FnvHashSet < ty:: Predicate < ' tcx > > ,
40
40
}
41
41
42
42
struct StackEntry < ' tcx > {
@@ -65,14 +65,11 @@ pub fn elaborate_trait_refs<'cx, 'tcx>(
65
65
66
66
pub fn elaborate_predicates < ' cx , ' tcx > (
67
67
tcx : & ' cx ty:: ctxt < ' tcx > ,
68
- predicates : Vec < ty:: Predicate < ' tcx > > )
68
+ mut predicates : Vec < ty:: Predicate < ' tcx > > )
69
69
-> Elaborator < ' cx , ' tcx >
70
70
{
71
- let visited: HashSet < ty:: Predicate < ' tcx > > =
72
- predicates. iter ( )
73
- . map ( |b| ( * b) . clone ( ) )
74
- . collect ( ) ;
75
-
71
+ let mut visited = FnvHashSet ( ) ;
72
+ predicates. retain ( |pred| visited. insert ( pred. clone ( ) ) ) ;
76
73
let entry = StackEntry { position : 0 , predicates : predicates } ;
77
74
Elaborator { tcx : tcx, stack : vec ! [ entry] , visited : visited }
78
75
}
0 commit comments