Preallocate correct state length.

This commit is contained in:
2018-12-12 13:08:35 +01:00
parent 247613555b
commit 8340f2c8fa

View File

@@ -78,7 +78,7 @@ impl Day12 {
} }
fn simulate(&self, state: &State) -> State { fn simulate(&self, state: &State) -> State {
let mut new_state = Vec::new(); let mut new_state = Vec::with_capacity(state.len() + 8);
let mut index = 0; let mut index = 0;
let mut last_idx = None; let mut last_idx = None;
for &(idx, b) in state { for &(idx, b) in state {