Avoid or reduce LINQ allocations required in various areas.

This commit is contained in:
RoosterDragon
2020-10-11 11:46:39 +01:00
committed by abcdefg30
parent da53d5b776
commit bb116034c7
9 changed files with 31 additions and 24 deletions

View File

@@ -1282,16 +1282,12 @@ namespace OpenRA
throw new ArgumentOutOfRangeException("maxRange",
"The requested range ({0}) cannot exceed the value of MaximumTileSearchRange ({1})".F(maxRange, Grid.MaximumTileSearchRange));
Func<CPos, bool> valid = Contains;
if (allowOutsideBounds)
valid = Tiles.Contains;
for (var i = minRange; i <= maxRange; i++)
{
foreach (var offset in Grid.TilesByDistance[i])
{
var t = offset + center;
if (valid(t))
if (allowOutsideBounds ? Tiles.Contains(t) : Contains(t))
yield return t;
}
}