Skip to content

Commit 046470b

Browse files
committed
perf(08/2015): use str slice instead of iterator to compare elements
1 parent 2e74882 commit 046470b

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@
9494
| [Day 5: Doesn't He Have Intern-Elves For This?](src/solutions/year2015/day05.rs) | ⭐⭐ | 0.261 | 0.987 |
9595
| [Day 6: Probably a Fire Hazard](src/solutions/year2015/day06.rs) | ⭐⭐ | 871.538 | 817.533 |
9696
| [Day 7: Some Assembly Required](src/solutions/year2015/day07.rs) | ⭐⭐ | 0.308 | 0.293 |
97-
| [Day 8: Matchsticks](src/solutions/year2015/day08.rs) | ⭐⭐ | 0.171 | 0.451 |
97+
| [Day 8: Matchsticks](src/solutions/year2015/day08.rs) | ⭐⭐ | 0.052 | 0.129 |
9898

9999
# TODO
100100

src/solutions/year2015/day08.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,9 @@ impl Day08 {
4242
break;
4343
}
4444

45-
if word.chars().nth(i).unwrap() == '\\' {
46-
if word.chars().nth(i + 1).unwrap() == 'x' {
45+
let slice = &word[i..=(i + 1)];
46+
if slice.starts_with('\\') {
47+
if slice == "\\x" {
4748
i += 3;
4849
} else {
4950
i += 1;

0 commit comments

Comments
 (0)