Skip to content

Commit

Permalink
preallocate a little memory for the DFS stack
Browse files Browse the repository at this point in the history
  • Loading branch information
kcaffrey committed Dec 22, 2023
1 parent 9443727 commit 8862af0
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ Solutions for [Advent of Code](https://adventofcode.com/) in [Rust](https://www.
| [Day 19](./src/bin/19.rs) | `83.9µs` | `90.9µs` |
| [Day 20](./src/bin/20.rs) | `323.9µs` | `1.2ms` |
| [Day 21](./src/bin/21.rs) | `64.1µs` | `494.7µs` |
| [Day 22](./src/bin/22.rs) | `85.3µs` | `205.8µs` |
| [Day 22](./src/bin/22.rs) | `82.4µs` | `202.8µs` |

**Total: 16.63ms**
**Total: 16.62ms**
<!--- benchmarking table --->

---
Expand Down
2 changes: 1 addition & 1 deletion src/bin/22.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ pub fn part_two(input: &str) -> Option<u32> {
.map(|brick| {
let mut fall_count = 0;
let mut visited = vec![false; tower.bricks.len()];
let mut stack = Vec::new();
let mut stack = Vec::with_capacity(16);
visited[brick] = true;
stack.push(brick);
while let Some(cur) = stack.pop() {
Expand Down

0 comments on commit 8862af0

Please sign in to comment.