Skip to content

Commit 1ab08ef

Browse files
committed
micro-optimize dominator code
1 parent 57f39ee commit 1ab08ef

File tree

1 file changed

+2
-2
lines changed
  • src/librustc_data_structures/graph/dominators

1 file changed

+2
-2
lines changed

src/librustc_data_structures/graph/dominators/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,13 @@ pub fn dominators_given_rpo<G: ControlFlowGraph>(
3838

3939
// compute the post order index (rank) for each node
4040
let mut post_order_rank: IndexVec<G::Node, usize> =
41-
IndexVec::from_elem_n(usize::default(), graph.num_nodes());
41+
(0..graph.num_nodes()).map(|_| 0).collect();
4242
for (index, node) in rpo.iter().rev().cloned().enumerate() {
4343
post_order_rank[node] = index;
4444
}
4545

4646
let mut immediate_dominators: IndexVec<G::Node, Option<G::Node>> =
47-
IndexVec::from_elem_n(Option::default(), graph.num_nodes());
47+
(0..graph.num_nodes()).map(|_| None).collect();
4848
immediate_dominators[start_node] = Some(start_node);
4949

5050
let mut changed = true;

0 commit comments

Comments
 (0)