Skip to content

Commit 543c6a3

Browse files
committed
Rollup merge of #31929 - dotdash:less_rallocx, r=alexcrichton
When foldings Substs, we map over VecPerParamSpace instances using EnumeratedItems which does not provide an accurate size_hint() in its Iterator implementation. This leads to quite a large number or reallocations. Providing a suitable size_hint() implementation reduces the time spent in item-bodies checking quite a bit. ``` crate | before | after | ~change -------|------------------------- core | 7.28s | 5.44s | -25% std | 2.07s | 1.88s | -9.2% syntax | 8.86s | 8.30s | -6.3% ```
2 parents 2d1843a + 31fef23 commit 543c6a3

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/librustc/middle/subst.rs

+5
Original file line numberDiff line numberDiff line change
@@ -555,6 +555,11 @@ impl<'a,T> Iterator for EnumeratedItems<'a,T> {
555555
None
556556
}
557557
}
558+
559+
fn size_hint(&self) -> (usize, Option<usize>) {
560+
let size = self.vec.as_slice().len();
561+
(size, Some(size))
562+
}
558563
}
559564

560565
impl<T> IntoIterator for VecPerParamSpace<T> {

0 commit comments

Comments
 (0)