OccupiedCells and TargetableCells must return arrays, not just enumerables.

This allows callers to efficiently enumerate these returned collections without the allocation and overhead imposed by the IEnumerable interface. All implementations were already returning arrays, so this only required a signature change.
This commit is contained in:
RoosterDragon
2017-11-17 21:23:17 +00:00
committed by Pavel Penev
parent da036c5728
commit 62ab6ae6f1
10 changed files with 13 additions and 15 deletions

View File

@@ -35,7 +35,7 @@ namespace OpenRA.Mods.Common.Traits
{
[Sync] readonly CPos location;
[Sync] readonly WPos position;
readonly IEnumerable<Pair<CPos, SubCell>> occupied;
readonly Pair<CPos, SubCell>[] occupied;
public Immobile(ActorInitializer init, ImmobileInfo info)
{
@@ -50,7 +50,7 @@ namespace OpenRA.Mods.Common.Traits
public CPos TopLeft { get { return location; } }
public WPos CenterPosition { get { return position; } }
public IEnumerable<Pair<CPos, SubCell>> OccupiedCells() { return occupied; }
public Pair<CPos, SubCell>[] OccupiedCells() { return occupied; }
void INotifyAddedToWorld.AddedToWorld(Actor self)
{