Skip to content

Commit d8015f6

Browse files
authored
Rollup merge of rust-lang#65648 - nnethercote:rm-intersect_opt, r=nikomatsakis
Eliminate `intersect_opt`. Its fourth argument is always `Some(pred)`, so the pattern matching is unnecessary. This commit inlines and removes it. r? @nikomatsakis
2 parents dd47daf + ddc1c27 commit d8015f6

File tree

1 file changed

+6
-21
lines changed
  • src/librustc_data_structures/graph/dominators

1 file changed

+6
-21
lines changed

Diff for: src/librustc_data_structures/graph/dominators/mod.rs

+6-21
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ pub fn dominators<G: ControlFlowGraph>(graph: &G) -> Dominators<G::Node> {
1717
dominators_given_rpo(graph, &rpo)
1818
}
1919

20-
pub fn dominators_given_rpo<G: ControlFlowGraph>(
20+
fn dominators_given_rpo<G: ControlFlowGraph>(
2121
graph: &G,
2222
rpo: &[G::Node],
2323
) -> Dominators<G::Node> {
@@ -43,14 +43,12 @@ pub fn dominators_given_rpo<G: ControlFlowGraph>(
4343
let mut new_idom = None;
4444
for pred in graph.predecessors(node) {
4545
if immediate_dominators[pred].is_some() {
46-
// (*)
4746
// (*) dominators for `pred` have been calculated
48-
new_idom = intersect_opt(
49-
&post_order_rank,
50-
&immediate_dominators,
51-
new_idom,
52-
Some(pred),
53-
);
47+
new_idom = Some(if let Some(new_idom) = new_idom {
48+
intersect(&post_order_rank, &immediate_dominators, new_idom, pred)
49+
} else {
50+
pred
51+
});
5452
}
5553
}
5654

@@ -67,19 +65,6 @@ pub fn dominators_given_rpo<G: ControlFlowGraph>(
6765
}
6866
}
6967

70-
fn intersect_opt<Node: Idx>(
71-
post_order_rank: &IndexVec<Node, usize>,
72-
immediate_dominators: &IndexVec<Node, Option<Node>>,
73-
node1: Option<Node>,
74-
node2: Option<Node>,
75-
) -> Option<Node> {
76-
match (node1, node2) {
77-
(None, None) => None,
78-
(Some(n), None) | (None, Some(n)) => Some(n),
79-
(Some(n1), Some(n2)) => Some(intersect(post_order_rank, immediate_dominators, n1, n2)),
80-
}
81-
}
82-
8368
fn intersect<Node: Idx>(
8469
post_order_rank: &IndexVec<Node, usize>,
8570
immediate_dominators: &IndexVec<Node, Option<Node>>,

0 commit comments

Comments
 (0)