Skip to content

Commit cf8e44e

Browse files
committed
Attempt to call shrink_to_fit at appropriate points to model potential space improvemetns in VecPerParamSpace.
1 parent 9153d8a commit cf8e44e

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

src/librustc/middle/subst.rs

+6
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,12 @@ impl<T> VecPerParamSpace<T> {
271271
}
272272
}
273273

274+
pub fn shrink_to_fit(&mut self) {
275+
self.vecs.mut0().shrink_to_fit();
276+
self.vecs.mut1().shrink_to_fit();
277+
self.vecs.mut2().shrink_to_fit();
278+
}
279+
274280
pub fn params_from_type(types: Vec<T>) -> VecPerParamSpace<T> {
275281
VecPerParamSpace::empty().with_vec(TypeSpace, types)
276282
}

src/librustc/middle/ty.rs

+3
Original file line numberDiff line numberDiff line change
@@ -4615,13 +4615,15 @@ pub fn construct_parameter_environment(
46154615
push_types_from_defs(tcx, &mut types, space,
46164616
generics.types.get_vec(space));
46174617
}
4618+
types.shrink_to_fit();
46184619

46194620
// map bound 'a => free 'a
46204621
let mut regions = VecPerParamSpace::empty();
46214622
for &space in subst::ParamSpace::all().iter() {
46224623
push_region_params(&mut regions, space, free_id,
46234624
generics.regions.get_vec(space));
46244625
}
4626+
regions.shrink_to_fit();
46254627

46264628
let free_substs = Substs {
46274629
types: types,
@@ -4637,6 +4639,7 @@ pub fn construct_parameter_environment(
46374639
push_bounds_from_defs(tcx, &mut bounds, space, &free_substs,
46384640
generics.types.get_vec(space));
46394641
}
4642+
bounds.shrink_to_fit();
46404643

46414644
debug!("construct_parameter_environment: free_id={} \
46424645
free_subst={} \

0 commit comments

Comments
 (0)