day05 part 2 prealloc vectors

This commit is contained in:
Johannes
2018-12-05 20:53:00 +01:00
parent d10d36498c
commit 5fa344dd55

View File

@@ -36,7 +36,7 @@ pub fn task2() {
fn reduce(input: &str) -> String { fn reduce(input: &str) -> String {
input input
.chars() .chars()
.fold(Vec::<char>::new(), |mut stack, c| { .fold(Vec::<char>::with_capacity(input.len()), |mut stack, c| {
let last: Option<char>; let last: Option<char>;
{ {
if let Some(c) = stack.last() { if let Some(c) = stack.last() {