From: Dylan MacKenzie Date: Sun, 19 Apr 2020 20:56:49 +0000 (-0700) Subject: Replace multiple calls to `predecessors_for` X-Git-Url: https://git.lizzy.rs/?a=commitdiff_plain;h=4e7469eaeaaa460828f0494de97b6ce4203a44a5;p=rust.git Replace multiple calls to `predecessors_for` ...with a single one to `predecessors`. `predecessors_for` requires taking the lock/incrementing the `RefCell` once each call. --- diff --git a/src/librustc_middle/mir/mod.rs b/src/librustc_middle/mir/mod.rs index ea3e59666d6..e476729c11b 100644 --- a/src/librustc_middle/mir/mod.rs +++ b/src/librustc_middle/mir/mod.rs @@ -2716,14 +2716,16 @@ pub fn is_predecessor_of<'tcx>(&self, other: Location, body: &Body<'tcx>) -> boo 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 = body.predecessors_for(other.block).to_vec(); + let mut queue: Vec = 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; }