From d0c23ef2dd1cedc966eddaae6dde0f62aec4f617 Mon Sep 17 00:00:00 2001 From: RoosterDragon Date: Sat, 24 Oct 2015 22:57:02 +0100 Subject: [PATCH] Prevent redundant enumerations in Attack.InnerTick. The armaments variable is enumerated several times, but the results won't change. If we cache it straight away we can improve performance. --- OpenRA.Mods.Common/Activities/Attack.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/OpenRA.Mods.Common/Activities/Attack.cs b/OpenRA.Mods.Common/Activities/Attack.cs index 2ec721b818..0f3c54a7db 100644 --- a/OpenRA.Mods.Common/Activities/Attack.cs +++ b/OpenRA.Mods.Common/Activities/Attack.cs @@ -68,8 +68,8 @@ namespace OpenRA.Mods.Common.Activities return NextActivity; // Drop the target once none of the weapons are effective against it - var armaments = attack.ChooseArmamentsForTarget(Target, forceAttack); - if (!armaments.Any()) + var armaments = attack.ChooseArmamentsForTarget(Target, forceAttack).ToList(); + if (armaments.Count == 0) return NextActivity; // Update ranges