diff options
author | Justin Worthe <justin@worthe-it.co.za> | 2018-05-31 21:59:21 +0200 |
---|---|---|
committer | Justin Worthe <justin@worthe-it.co.za> | 2018-05-31 21:59:21 +0200 |
commit | b26fc5909197094acb6ef85f3d1f17eb13e11f4a (patch) | |
tree | 9365148a4965d53ced6e60919c815d6a492f201f /src | |
parent | a2207673af2da6121544aecd2d5370e98926041e (diff) |
Profile driven optimization of missile moving
Diffstat (limited to 'src')
-rw-r--r-- | src/engine/mod.rs | 5 |
1 files changed, 1 insertions, 4 deletions
diff --git a/src/engine/mod.rs b/src/engine/mod.rs index 75583e3..2ad9a73 100644 --- a/src/engine/mod.rs +++ b/src/engine/mod.rs @@ -205,7 +205,7 @@ impl GameState { Some(point) => { missile.pos = point; // TODO latest game engine may be checking building health here - for hit in opponent_buildings.iter_mut().filter(|b| b.pos == point) { + if let Some(mut hit) = opponent_buildings.iter_mut().find(|b| b.pos == point) { let damage = cmp::min(missile.damage, hit.health); hit.health -= damage; missile.speed = 0; @@ -213,12 +213,9 @@ impl GameState { } } - /* - check is necessary if speed could be > 1, which isn't the case yet if missile.speed == 0 { break; } - */ } } missiles.retain(|m| m.speed > 0); |