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:
committed by
Pavel Penev
parent
da036c5728
commit
62ab6ae6f1
@@ -15,11 +15,9 @@ using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common
|
||||
{
|
||||
using OccupiedCells = IEnumerable<Pair<CPos, SubCell>>;
|
||||
|
||||
public static class ShroudExts
|
||||
{
|
||||
public static bool AnyExplored(this Shroud shroud, OccupiedCells cells)
|
||||
public static bool AnyExplored(this Shroud shroud, Pair<CPos, SubCell>[] cells)
|
||||
{
|
||||
// PERF: Avoid LINQ.
|
||||
foreach (var cell in cells)
|
||||
@@ -29,7 +27,7 @@ namespace OpenRA.Mods.Common
|
||||
return false;
|
||||
}
|
||||
|
||||
public static bool AnyVisible(this Shroud shroud, OccupiedCells cells)
|
||||
public static bool AnyVisible(this Shroud shroud, Pair<CPos, SubCell>[] cells)
|
||||
{
|
||||
// PERF: Avoid LINQ.
|
||||
foreach (var cell in cells)
|
||||
|
||||
Reference in New Issue
Block a user