- commit
- 34ee53f4ebd22b2f40633f333929ee09e86589f8
- parent
- b2ed31eb0d5b555e6e04c92f1c5a3a827e4ceb1e
- Author
- Tobias Bengfort <tobias.bengfort@posteo.de>
- Date
- 2023-02-18 22:40
perf: avoid sqrt
Diffstat
| M | src/main.rs | 4 | ++-- |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/main.rs b/src/main.rs
@@ -264,8 +264,8 @@ fn main() {
264 264 diamonds = diamonds.into_iter().filter(|diamond| {
265 265 let dx = player.x - diamond.x;
266 266 let dy = player.y - diamond.y;
267 -1 let d = (dx * dx + dy * dy).sqrt();
268 -1 if d < player.diamond_radius {
-1 267 let d = dx * dx + dy * dy;
-1 268 if d < player.diamond_radius * player.diamond_radius {
269 269 player.xp += 1;
270 270 return false;
271 271 } else{