Skip to content

Commit

Permalink
day 16: using with_capacity to icrease performance
Browse files Browse the repository at this point in the history
  • Loading branch information
livexia committed Dec 16, 2023
1 parent d58d499 commit 5c6aec6
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions aoc16/src/main.rs
Expand Up @@ -95,9 +95,9 @@ fn bfs(start_pos: Coord, dir: Direction, grid: &Grid) -> usize {
queue.push_back((start_pos, d));
}

let mut visited = HashSet::new();
let mut visited = HashSet::with_capacity(20_000);

let mut energized = HashSet::new();
let mut energized = HashSet::with_capacity(10_000);

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

0 comments on commit 5c6aec6

Please sign in to comment.