提交 e62ce980 编写于 作者: L ljedrz

nll: improve allocations

上级 1dceaddf
......@@ -141,6 +141,7 @@ fn visit_assign(
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 @@ fn visit_terminator(
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
......
......@@ -279,9 +279,8 @@ fn is_borrow_location_in_loop(
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 @@ fn is_borrow_location_in_loop(
},
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()));
},
_ => {},
}
......
......@@ -462,9 +462,8 @@ fn give_name_if_we_can_match_hir_ty(
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) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册