mirror of
https://github.com/bertptrs/adventofcode.git
synced 2025-12-27 05:40:32 +01:00
Slightly better ICACHE hits
This commit is contained in:
@@ -70,6 +70,11 @@ fn scenery<'a>(
|
||||
tree_stack.clear();
|
||||
|
||||
for (i, (&val, score)) in values.into_iter().zip(visible).enumerate() {
|
||||
scenery_helper(i, tree_stack, val, score);
|
||||
}
|
||||
}
|
||||
|
||||
fn scenery_helper(i: usize, tree_stack: &mut Vec<(usize, u8)>, val: u8, score: &mut usize) {
|
||||
if i > 0 {
|
||||
let mut first = 0;
|
||||
|
||||
@@ -95,7 +100,6 @@ fn scenery<'a>(
|
||||
*score = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn part2(input: &[u8]) -> Result<String> {
|
||||
let width = input
|
||||
@@ -106,7 +110,7 @@ pub fn part2(input: &[u8]) -> Result<String> {
|
||||
|
||||
let mut score = vec![1; width * height];
|
||||
|
||||
let mut tree_stack = Vec::new();
|
||||
let mut tree_stack = Vec::with_capacity(10);
|
||||
|
||||
// Horizontal striping
|
||||
for (y, row) in input.chunks_exact(width + 1).enumerate() {
|
||||
|
||||
Reference in New Issue
Block a user