nll: improve allocations

This commit is contained in:
ljedrz 2018-10-17 16:52:35 +02:00
parent 1dceaddfbe
commit e62ce98009
3 changed files with 10 additions and 10 deletions

View File

@ -141,6 +141,7 @@ impl<'cg, 'cx, 'gcx, 'tcx> Visitor<'tcx> for ConstraintGeneration<'cg, 'cx, 'gcx
if let Some(all_facts) = self.all_facts {
if let Place::Local(temp) = place {
if let Some(borrow_indices) = self.borrow_set.local_map.get(temp) {
all_facts.killed.reserve(borrow_indices.len());
for &borrow_index in borrow_indices {
let location_index = self.location_table.mid_index(location);
all_facts.killed.push((borrow_index, location_index));
@ -164,7 +165,9 @@ impl<'cg, 'cx, 'gcx, 'tcx> Visitor<'tcx> for ConstraintGeneration<'cg, 'cx, 'gcx
self.location_table.mid_index(location),
));
for successor_block in terminator.successors() {
let successor_blocks = terminator.successors();
all_facts.cfg_edge.reserve(successor_blocks.size_hint().0);
for successor_block in successor_blocks {
all_facts.cfg_edge.push((
self.location_table.mid_index(location),
self.location_table

View File

@ -279,9 +279,8 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
pending_locations.push(target.start_location());
},
TerminatorKind::SwitchInt { ref targets, .. } => {
for target in targets {
pending_locations.push(target.start_location());
}
pending_locations.extend(
targets.into_iter().map(|target| target.start_location()));
},
TerminatorKind::Drop { target, unwind, .. } |
TerminatorKind::DropAndReplace { target, unwind, .. } |
@ -303,9 +302,8 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
},
TerminatorKind::FalseEdges { real_target, ref imaginary_targets, .. } => {
pending_locations.push(real_target.start_location());
for target in imaginary_targets {
pending_locations.push(target.start_location());
}
pending_locations.extend(
imaginary_targets.into_iter().map(|target| target.start_location()));
},
_ => {},
}

View File

@ -462,9 +462,8 @@ impl<'tcx> RegionInferenceContext<'tcx> {
argument_hir_ty: &hir::Ty,
counter: &mut usize,
) -> Option<RegionName> {
let search_stack: &mut Vec<(Ty<'tcx>, &hir::Ty)> = &mut Vec::new();
search_stack.push((argument_ty, argument_hir_ty));
let search_stack: &mut Vec<(Ty<'tcx>, &hir::Ty)> =
&mut vec![(argument_ty, argument_hir_ty)];
while let Some((ty, hir_ty)) = search_stack.pop() {
match (&ty.sty, &hir_ty.node) {