Skip to content

Commit 04b99bc

Browse files
committed
rustc/ty: improve allocations
1 parent db17164 commit 04b99bc

File tree

3 files changed

+3
-5
lines changed

3 files changed

+3
-5
lines changed

src/librustc/ty/outlives.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -180,9 +180,5 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
180180
}
181181

182182
fn push_region_constraints<'tcx>(out: &mut Vec<Component<'tcx>>, regions: Vec<ty::Region<'tcx>>) {
183-
for r in regions {
184-
if !r.is_late_bound() {
185-
out.push(Component::Region(r));
186-
}
187-
}
183+
out.extend(regions.iter().filter(|&r| !r.is_late_bound()).map(|r| Component::Region(r)));
188184
}

src/librustc/ty/subst.rs

+1
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,7 @@ impl<'a, 'gcx, 'tcx> Substs<'tcx> {
229229
mk_kind: &mut F)
230230
where F: FnMut(&ty::GenericParamDef, &[Kind<'tcx>]) -> Kind<'tcx>
231231
{
232+
substs.reserve(defs.params.len());
232233
for param in &defs.params {
233234
let kind = mk_kind(param, substs);
234235
assert_eq!(param.index as usize, substs.len());

src/librustc/ty/wf.rs

+1
Original file line numberDiff line numberDiff line change
@@ -493,6 +493,7 @@ impl<'a, 'gcx, 'tcx> WfPredicates<'a, 'gcx, 'tcx> {
493493

494494
let explicit_bound = region;
495495

496+
self.out.reserve(implicit_bounds.len());
496497
for implicit_bound in implicit_bounds {
497498
let cause = self.cause(traits::ObjectTypeBound(ty, explicit_bound));
498499
let outlives = ty::Binder::dummy(

0 commit comments

Comments
 (0)