Optimized integer parsing in day 7 part 2
This commit is contained in:
parent
6d92264741
commit
4073f69c84
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -1,5 +1,5 @@
|
||||||
/target
|
/target
|
||||||
go.mod
|
go.mod
|
||||||
go.sum
|
go.sum
|
||||||
test.go
|
*.go
|
||||||
test
|
test
|
||||||
|
|
|
@ -48,8 +48,10 @@ fn solution(input: impl Iterator<Item = &'static str>) -> u32 {
|
||||||
},
|
},
|
||||||
|
|
||||||
_ => {
|
_ => {
|
||||||
let (size, _) = line.split_once(' ').unwrap();
|
let size = line
|
||||||
let size = size.parse::<u32>().unwrap();
|
.bytes()
|
||||||
|
.take_while(|&c| c != b' ')
|
||||||
|
.fold(0u32, |a, x| a * 10 + (x - b'0') as u32);
|
||||||
current_folder_size += size;
|
current_folder_size += size;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user