Skip to content

Commit 97db376

Browse files
committed
Reuse a Vec in mir simplification
1 parent 3d8778d commit 97db376

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/librustc_mir/transform/simplify.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ impl<'a, 'tcx> CfgSimplifier<'a, 'tcx> {
9494
self.strip_nops();
9595

9696
let mut start = START_BLOCK;
97+
let mut new_stmts = vec![];
9798

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

117-
let mut new_stmts = vec![];
118118
let mut inner_changed = true;
119119
while inner_changed {
120120
inner_changed = false;
@@ -124,7 +124,7 @@ impl<'a, 'tcx> CfgSimplifier<'a, 'tcx> {
124124
}
125125

126126
let data = &mut self.basic_blocks[bb];
127-
data.statements.extend(new_stmts);
127+
data.statements.extend(new_stmts.drain(..));
128128
data.terminator = Some(terminator);
129129

130130
changed |= inner_changed;

0 commit comments

Comments
 (0)