Reduce allocations in the main game loop.

- Cache the shroud projection even for flat maps to avoid allocating single element arrays.
- Avoid LINQ in shroud and map projection queries to avoid enumerator allocations.
- Avoid LINQ in calculation of sync values.
- Cache enumerables in ProductionQueue.
- Cache delegate in HackyAI.
This commit is contained in:
RoosterDragon
2015-08-12 23:45:11 +01:00
parent 1e817fad76
commit d415d3ba4e
7 changed files with 105 additions and 65 deletions

View File

@@ -270,7 +270,11 @@ namespace OpenRA.Traits
if (!map.Contains(uv))
return false;
return map.ProjectedCellsCovering(uv).Any(isExploredTest);
foreach (var puv in map.ProjectedCellsCovering(uv))
if (IsExplored(puv))
return true;
return false;
}
public bool IsExplored(PPos puv)
@@ -316,7 +320,11 @@ namespace OpenRA.Traits
if (!visibleCount.Contains(uv))
return false;
return map.ProjectedCellsCovering(uv).Any(isVisibleTest);
foreach (var puv in map.ProjectedCellsCovering(uv))
if (IsVisible(puv))
return true;
return false;
}
// In internal shroud coords