Skip to content

Commit 5c6aec6

Browse files
committed
day 16: using with_capacity to icrease performance
1 parent d58d499 commit 5c6aec6

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

aoc16/src/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,9 @@ fn bfs(start_pos: Coord, dir: Direction, grid: &Grid) -> usize {
9595
queue.push_back((start_pos, d));
9696
}
9797

98-
let mut visited = HashSet::new();
98+
let mut visited = HashSet::with_capacity(20_000);
9999

100-
let mut energized = HashSet::new();
100+
let mut energized = HashSet::with_capacity(10_000);
101101

102102
while let Some((pos, dir)) = queue.pop_front() {
103103
energized.insert(pos);

0 commit comments

Comments
 (0)