From dc2e44da3657e80170d51839c1c4f889fae06b03 Mon Sep 17 00:00:00 2001 From: RoosterDragon Date: Sat, 29 Nov 2014 02:20:42 +0000 Subject: [PATCH] Change some Exts.MakeArray calls into Enumerable.Range. Avoid creating some arrays where sequences will suffice. --- OpenRA.Mods.RA/Attack/AttackGarrisoned.cs | 2 +- OpenRA.Mods.RA/LimitedAmmo.cs | 6 ++++-- OpenRA.Mods.RA/StoresResources.cs | 7 ++++--- OpenRA.Mods.RA/Widgets/Logic/LobbyUtils.cs | 2 +- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/OpenRA.Mods.RA/Attack/AttackGarrisoned.cs b/OpenRA.Mods.RA/Attack/AttackGarrisoned.cs index 0cfeba787f..d7046919bd 100644 --- a/OpenRA.Mods.RA/Attack/AttackGarrisoned.cs +++ b/OpenRA.Mods.RA/Attack/AttackGarrisoned.cs @@ -117,7 +117,7 @@ namespace OpenRA.Mods.RA { // Pick a random port that faces the target var bodyYaw = facing.Value != null ? WAngle.FromFacing(facing.Value.Facing) : WAngle.Zero; - var indices = Exts.MakeArray(Ports.Length, i => i).Shuffle(self.World.SharedRandom); + var indices = Enumerable.Range(0, Ports.Length).Shuffle(self.World.SharedRandom); foreach (var i in indices) { var yaw = bodyYaw + Ports[i].Yaw; diff --git a/OpenRA.Mods.RA/LimitedAmmo.cs b/OpenRA.Mods.RA/LimitedAmmo.cs index 762a800606..6228c0dbb4 100644 --- a/OpenRA.Mods.RA/LimitedAmmo.cs +++ b/OpenRA.Mods.RA/LimitedAmmo.cs @@ -9,6 +9,7 @@ #endregion using System.Collections.Generic; +using System.Linq; using OpenRA.Traits; namespace OpenRA.Mods.RA @@ -66,8 +67,9 @@ namespace OpenRA.Mods.RA public IEnumerable GetPips(Actor self) { var pips = Info.PipCount != 0 ? Info.PipCount : Info.Ammo; - return Exts.MakeArray(pips, - i => (ammo * pips) / Info.Ammo > i ? Info.PipType : Info.PipTypeEmpty); + return Enumerable.Range(0, pips).Select(i => + (ammo * pips) / Info.Ammo > i ? + Info.PipType : Info.PipTypeEmpty); } } } diff --git a/OpenRA.Mods.RA/StoresResources.cs b/OpenRA.Mods.RA/StoresResources.cs index 774f667ad2..6052083f5d 100644 --- a/OpenRA.Mods.RA/StoresResources.cs +++ b/OpenRA.Mods.RA/StoresResources.cs @@ -9,6 +9,7 @@ #endregion using System.Collections.Generic; +using System.Linq; using OpenRA.Traits; namespace OpenRA.Mods.RA @@ -57,9 +58,9 @@ namespace OpenRA.Mods.RA public IEnumerable GetPips(Actor self) { - return Exts.MakeArray(Info.PipCount, - i => (Player.Resources * Info.PipCount > i * Player.ResourceCapacity) - ? Info.PipColor : PipType.Transparent); + return Enumerable.Range(0, Info.PipCount).Select(i => + Player.Resources * Info.PipCount > i * Player.ResourceCapacity + ? Info.PipColor : PipType.Transparent); } public bool ShouldExplode(Actor self) { return Stored > 0; } diff --git a/OpenRA.Mods.RA/Widgets/Logic/LobbyUtils.cs b/OpenRA.Mods.RA/Widgets/Logic/LobbyUtils.cs index 935440bdc8..41723428af 100644 --- a/OpenRA.Mods.RA/Widgets/Logic/LobbyUtils.cs +++ b/OpenRA.Mods.RA/Widgets/Logic/LobbyUtils.cs @@ -84,7 +84,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic return item; }; - var options = Exts.MakeArray(teamCount + 1, i => i).ToList(); + var options = Enumerable.Range(0, teamCount + 1); dropdown.ShowDropDown("TEAM_DROPDOWN_TEMPLATE", 150, options, setupItem); }