Skip to content

Commit

Permalink
Replace multiple calls to predecessors_for
Browse files Browse the repository at this point in the history
...with a single one to `predecessors`. `predecessors_for` requires
taking the lock/incrementing the `RefCell` once each call.
  • Loading branch information
ecstatic-morse committed Apr 22, 2020
1 parent 2ff1fc9 commit 4e7469e
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/librustc_middle/mir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2716,14 +2716,16 @@ impl Location {
return true;
}

let predecessors = body.predecessors();

// If we're in another block, then we want to check that block is a predecessor of `other`.
let mut queue: Vec<BasicBlock> = body.predecessors_for(other.block).to_vec();
let mut queue: Vec<BasicBlock> = predecessors[other.block].to_vec();
let mut visited = FxHashSet::default();

while let Some(block) = queue.pop() {
// If we haven't visited this block before, then make sure we visit it's predecessors.
if visited.insert(block) {
queue.extend(body.predecessors_for(block).iter().cloned());
queue.extend(predecessors[block].iter().cloned());
} else {
continue;
}
Expand Down

0 comments on commit 4e7469e

Please sign in to comment.