File tree 1 file changed +15
-2
lines changed
1 file changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -1223,8 +1223,21 @@ BraceStructTypeFoldableImpl! {
1223
1223
1224
1224
impl < ' tcx > TypeFoldable < ' tcx > for & ' tcx ty:: List < ty:: Predicate < ' tcx > > {
1225
1225
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
+ }
1228
1241
}
1229
1242
1230
1243
fn super_visit_with < V : TypeVisitor < ' tcx > > ( & self , visitor : & mut V ) -> bool {
You can’t perform that action at this time.
0 commit comments