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
|
||||
go.mod
|
||||
go.sum
|
||||
test.go
|
||||
*.go
|
||||
test
|
||||
|
|
|
@ -48,8 +48,10 @@ fn solution(input: impl Iterator<Item = &'static str>) -> u32 {
|
|||
},
|
||||
|
||||
_ => {
|
||||
let (size, _) = line.split_once(' ').unwrap();
|
||||
let size = size.parse::<u32>().unwrap();
|
||||
let size = line
|
||||
.bytes()
|
||||
.take_while(|&c| c != b' ')
|
||||
.fold(0u32, |a, x| a * 10 + (x - b'0') as u32);
|
||||
current_folder_size += size;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user