From d9dd96ca35697c634253bce38f39d4dcbefd5caa Mon Sep 17 00:00:00 2001 From: RoosterDragon Date: Thu, 20 Aug 2015 21:12:21 +0100 Subject: [PATCH] Speed up Map.ContainsAllProjectedCellsCovering on flat maps. This method gets called often via Contains calls. We can significantly speed up the method for flat maps since we know the projection and it is trivial to perform. This avoids an expensive projection lookup. --- OpenRA.Game/Map/Map.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/OpenRA.Game/Map/Map.cs b/OpenRA.Game/Map/Map.cs index 2f578880cd..3f3f45a160 100644 --- a/OpenRA.Game/Map/Map.cs +++ b/OpenRA.Game/Map/Map.cs @@ -767,6 +767,9 @@ namespace OpenRA bool ContainsAllProjectedCellsCovering(MPos uv) { + if (MaximumTerrainHeight == 0) + return Contains((PPos)uv); + foreach (var puv in ProjectedCellsCovering(uv)) if (!Contains(puv)) return false;