From 2dd1bd2d3937fe6a18e19e752477fad9f303dea0 Mon Sep 17 00:00:00 2001 From: RoosterDragon Date: Wed, 22 Nov 2017 19:04:09 +0000 Subject: [PATCH] Initialize map inverse cell projections with capacity 1. This prevents the capacity being set to 4 when the first item is added. For flat maps, the inverse projection will only ever be of size 1, thus this is sufficient capacity. For isometric maps, 1 is often sufficient, we only need more near height changes where the discontinuity means multiple cells may project back. We can pay for some reallocations to expand the size in these cases. On flat maps, this reduces the memory required by the backing array 4x. --- OpenRA.Game/Map/Map.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenRA.Game/Map/Map.cs b/OpenRA.Game/Map/Map.cs index 82c1407d6e..e9bd0fc47a 100644 --- a/OpenRA.Game/Map/Map.cs +++ b/OpenRA.Game/Map/Map.cs @@ -429,7 +429,7 @@ namespace OpenRA { var uv = cell.ToMPos(Grid.Type); cellProjection[uv] = new PPos[0]; - inverseCellProjection[uv] = new List(); + inverseCellProjection[uv] = new List(1); } // Initialize projections