Skip to content

Commit 9c6d6dc

Browse files
authored
Slightly more efficient vec initialization (#120)
This will, at least on x86_64, compile down to simpler, shorter assembly that uses a zeroed allocation instead of a regular allocation, a memset and various `raw_vec` methods.
1 parent 2bd0325 commit 9c6d6dc

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

src/postorder.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ pub fn calculate<'a, SuccFn: Fn(Block) -> &'a [Block]>(
1818
let mut ret = vec![];
1919

2020
// State: visited-block map, and explicit DFS stack.
21-
let mut visited = vec![];
22-
visited.resize(num_blocks, false);
21+
let mut visited = vec![false; num_blocks];
2322

2423
struct State<'a> {
2524
block: Block,

0 commit comments

Comments
 (0)