There are a large number of unnecessary allocations in the system, primarily in the addItion_map, removal_map and flow_map hashmaps and the hashmap returned by proposed lateral flow to neighbors.
Instead, we should add:
/// Cache of water to be added and removed from each tile during [`horizontal_water_movement`].
///
/// This is for performance reasons, as it allows us to reduce allocations by reusing the same space.
#[derive(Component, Default, Debug, PartialEq, Clone, Copy, Serialize, Deserialize)]
pub struct LateralWaterCache {
/// The amount of water to be added to each tile.
incoming: Volume,
/// The amount of water to be added to each neighbor.
outgoing: [Volume; 6],
}
There are a large number of unnecessary allocations in the system, primarily in the
addItion_map
,removal_map
andflow_map
hashmaps and the hashmap returned by proposed lateral flow to neighbors.Instead, we should add:
to the
WaterBundle
.Then, this should be mutated in place.