File tree Expand file tree Collapse file tree 1 file changed +15
-2
lines changed Expand file tree Collapse file tree 1 file changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -1223,8 +1223,21 @@ BraceStructTypeFoldableImpl! {
12231223
12241224impl < ' tcx > TypeFoldable < ' tcx > for & ' tcx ty:: List < ty:: Predicate < ' tcx > > {
12251225 fn super_fold_with < F : TypeFolder < ' tcx > > ( & self , folder : & mut F ) -> Self {
1226- let v = self . iter ( ) . map ( |p| p. fold_with ( folder) ) . collect :: < SmallVec < [ _ ; 8 ] > > ( ) ;
1227- folder. tcx ( ) . intern_predicates ( & v)
1226+ // This code is hot enough that it's worth specializing for a list of
1227+ // length 0. (No other length is common enough to be worth singling
1228+ // out).
1229+ if self . len ( ) == 0 {
1230+ self
1231+ } else {
1232+ // Don't bother interning if nothing changed, which is the common
1233+ // case.
1234+ let v = self . iter ( ) . map ( |p| p. fold_with ( folder) ) . collect :: < SmallVec < [ _ ; 8 ] > > ( ) ;
1235+ if v[ ..] == self [ ..] {
1236+ self
1237+ } else {
1238+ folder. tcx ( ) . intern_predicates ( & v)
1239+ }
1240+ }
12281241 }
12291242
12301243 fn super_visit_with < V : TypeVisitor < ' tcx > > ( & self , visitor : & mut V ) -> bool {
You can’t perform that action at this time.
0 commit comments