summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJustin Worthe <justin@worthe-it.co.za>2018-05-17 00:01:52 +0200
committerJustin Worthe <justin@worthe-it.co.za>2018-05-17 00:01:52 +0200
commitac2951451cc1fc26b6d8a7a0aa1267535b36b3d1 (patch)
tree93cb33cd998531889d3cebaf4a93774c4a4ab02d /src
parent8c611df4d8bc412588b25ca09577827cc32971e9 (diff)
Improved perf of removing item from unoccupied cells list
Diffstat (limited to 'src')
-rw-r--r--src/engine/mod.rs4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/engine/mod.rs b/src/engine/mod.rs
index 227a7f6..6626c0d 100644
--- a/src/engine/mod.rs
+++ b/src/engine/mod.rs
@@ -165,7 +165,9 @@ impl GameState {
player.energy_generated += building.energy_generated_per_turn;
buildings.push(building);
}
- unoccupied_cells.retain(|&pos| pos != p);
+
+ let to_remove_index = unoccupied_cells.iter().position(|&pos| pos == p).unwrap();
+ unoccupied_cells.swap_remove(to_remove_index);
},
}
}