Skip to content

Commit 5165099

Browse files
committed
perf(18/2024): optimize removing redundant cloning
1 parent 9f20ee9 commit 5165099

File tree

2 files changed

+3
-9
lines changed

2 files changed

+3
-9
lines changed

readme.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
| [Day 15: Warehouse Woes](src/solutions/year2024/day15.rs) | ⭐⭐ | 7.226 | 9.084 |
2929
| [Day 16: Reindeer Maze](src/solutions/year2024/day16.rs) || 6.478 | - |
3030
| [Day 17: Chronospatial Computer](src/solutions/year2024/day17.rs) | - | - | - |
31-
| [Day 18: RAM Run](src/solutions/year2024/day18.rs) | ⭐⭐ | 2.487 | 431.665a |
31+
| [Day 18: RAM Run](src/solutions/year2024/day18.rs) | ⭐⭐ | 2.487 | 379.772 |
3232
| [Day 19: Linen Layout](src/solutions/year2024/day19.rs) | ⭐⭐ | 2.923 | 22.751 |
3333

3434
# 2023

src/solutions/year2024/day18.rs

+2-8
Original file line numberDiff line numberDiff line change
@@ -88,14 +88,8 @@ impl Day18 {
8888
return true;
8989
}
9090

91-
let neighbours: Vec<Point> = current
92-
.adjacent()
93-
.into_iter()
94-
.filter(|p| !blocked.contains(p) && self.surface.contains(*p))
95-
.collect();
96-
97-
for next in neighbours {
98-
if visited.insert(next) {
91+
for next in current.adjacent() {
92+
if visited.insert(next) && self.surface.contains(next) && !blocked.contains(&next) {
9993
queue.push(next);
10094
}
10195
}

0 commit comments

Comments
 (0)