Skip to content

Commit 86334c7

Browse files
committed
remove unnecessary intermediate vector from copy
1 parent b4f3232 commit 86334c7

File tree

1 file changed

+14
-18
lines changed
  • src/librustc_mir/borrow_check/nll/region_infer

1 file changed

+14
-18
lines changed

src/librustc_mir/borrow_check/nll/region_infer/mod.rs

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -471,35 +471,31 @@ impl<'tcx> RegionInferenceContext<'tcx> {
471471
changed |= new;
472472

473473
let block_data = &mir[p.block];
474-
let successor_points = if p.statement_index < block_data.statements.len() {
475-
vec![
476-
Location {
477-
statement_index: p.statement_index + 1,
478-
..p
479-
},
480-
]
474+
475+
let start_stack_len = stack.len();
476+
477+
if p.statement_index < block_data.statements.len() {
478+
stack.push(Location {
479+
statement_index: p.statement_index + 1,
480+
..p
481+
});
481482
} else {
482-
block_data
483-
.terminator()
484-
.successors()
485-
.iter()
486-
.map(|&basic_block| {
483+
stack.extend(block_data.terminator().successors().iter().map(
484+
|&basic_block| {
487485
Location {
488486
statement_index: 0,
489487
block: basic_block,
490488
}
491-
})
492-
.collect::<Vec<_>>()
493-
};
489+
},
490+
));
491+
}
494492

495-
if successor_points.is_empty() {
493+
if stack.len() == start_stack_len {
496494
// If we reach the END point in the graph, then copy
497495
// over any skolemized end points in the `from_region`
498496
// and make sure they are included in the `to_region`.
499497
changed |=
500498
inferred_values.add_universal_regions_outlived_by(from_region, to_region);
501-
} else {
502-
stack.extend(successor_points);
503499
}
504500
}
505501

0 commit comments

Comments
 (0)