Skip to content

Commit

Permalink
Attempt to call shrink_to_fit at appropriate points to model potent…
Browse files Browse the repository at this point in the history
…ial space improvemetns in `VecPerParamSpace`.
  • Loading branch information
pnkfelix committed Jul 3, 2014
1 parent 9153d8a commit cf8e44e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/librustc/middle/subst.rs
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,12 @@ impl<T> VecPerParamSpace<T> {
}
}

pub fn shrink_to_fit(&mut self) {
self.vecs.mut0().shrink_to_fit();
self.vecs.mut1().shrink_to_fit();
self.vecs.mut2().shrink_to_fit();
}

pub fn params_from_type(types: Vec<T>) -> VecPerParamSpace<T> {
VecPerParamSpace::empty().with_vec(TypeSpace, types)
}
Expand Down
3 changes: 3 additions & 0 deletions src/librustc/middle/ty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4615,13 +4615,15 @@ pub fn construct_parameter_environment(
push_types_from_defs(tcx, &mut types, space,
generics.types.get_vec(space));
}
types.shrink_to_fit();

// map bound 'a => free 'a
let mut regions = VecPerParamSpace::empty();
for &space in subst::ParamSpace::all().iter() {
push_region_params(&mut regions, space, free_id,
generics.regions.get_vec(space));
}
regions.shrink_to_fit();

let free_substs = Substs {
types: types,
Expand All @@ -4637,6 +4639,7 @@ pub fn construct_parameter_environment(
push_bounds_from_defs(tcx, &mut bounds, space, &free_substs,
generics.types.get_vec(space));
}
bounds.shrink_to_fit();

debug!("construct_parameter_environment: free_id={} \
free_subst={} \
Expand Down

0 comments on commit cf8e44e

Please sign in to comment.