Skip to content

Commit

Permalink
Auto merge of #68551 - Marwes:allocations_mir, r=<try>
Browse files Browse the repository at this point in the history
perf: Reuse a Vec in mir simplification

Just moves the vec out of the outer loop so it is reused every iteration
  • Loading branch information
bors committed Jan 26, 2020
2 parents 3d8778d + 97db376 commit 874bb3e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/librustc_mir/transform/simplify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ impl<'a, 'tcx> CfgSimplifier<'a, 'tcx> {
self.strip_nops();

let mut start = START_BLOCK;
let mut new_stmts = vec![];

loop {
let mut changed = false;
Expand All @@ -114,7 +115,6 @@ impl<'a, 'tcx> CfgSimplifier<'a, 'tcx> {
self.collapse_goto_chain(successor, &mut changed);
}

let mut new_stmts = vec![];
let mut inner_changed = true;
while inner_changed {
inner_changed = false;
Expand All @@ -124,7 +124,7 @@ impl<'a, 'tcx> CfgSimplifier<'a, 'tcx> {
}

let data = &mut self.basic_blocks[bb];
data.statements.extend(new_stmts);
data.statements.extend(new_stmts.drain(..));
data.terminator = Some(terminator);

changed |= inner_changed;
Expand Down

0 comments on commit 874bb3e

Please sign in to comment.