diff options
| author | Niko Matsakis <niko@alum.mit.edu> | 2017-12-03 05:29:37 -0500 |
|---|---|---|
| committer | Niko Matsakis <niko@alum.mit.edu> | 2017-12-15 10:10:55 -0500 |
| commit | 86334c711648cc17bba9955f955a6710159bd6f7 (patch) | |
| tree | cd704b744dabcf69eb4391f8f12a081fef9fe3a0 | |
| parent | b4f323254a2cf227852eec1b40db0b152fc6042c (diff) | |
| download | rust-86334c711648cc17bba9955f955a6710159bd6f7.tar.gz rust-86334c711648cc17bba9955f955a6710159bd6f7.zip | |
remove unnecessary intermediate vector from `copy`
| -rw-r--r-- | src/librustc_mir/borrow_check/nll/region_infer/mod.rs | 32 |
1 files changed, 14 insertions, 18 deletions
diff --git a/src/librustc_mir/borrow_check/nll/region_infer/mod.rs b/src/librustc_mir/borrow_check/nll/region_infer/mod.rs index c926c7432bb..dfa7ce86875 100644 --- a/src/librustc_mir/borrow_check/nll/region_infer/mod.rs +++ b/src/librustc_mir/borrow_check/nll/region_infer/mod.rs @@ -471,35 +471,31 @@ impl<'tcx> RegionInferenceContext<'tcx> { changed |= new; let block_data = &mir[p.block]; - let successor_points = if p.statement_index < block_data.statements.len() { - vec![ - Location { - statement_index: p.statement_index + 1, - ..p - }, - ] + + let start_stack_len = stack.len(); + + if p.statement_index < block_data.statements.len() { + stack.push(Location { + statement_index: p.statement_index + 1, + ..p + }); } else { - block_data - .terminator() - .successors() - .iter() - .map(|&basic_block| { + stack.extend(block_data.terminator().successors().iter().map( + |&basic_block| { Location { statement_index: 0, block: basic_block, } - }) - .collect::<Vec<_>>() - }; + }, + )); + } - if successor_points.is_empty() { + if stack.len() == start_stack_len { // If we reach the END point in the graph, then copy // over any skolemized end points in the `from_region` // and make sure they are included in the `to_region`. changed |= inferred_values.add_universal_regions_outlived_by(from_region, to_region); - } else { - stack.extend(successor_points); } } |
