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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user