From a1f974bd404703a5c9719797ef707d16ac29d0d8 Mon Sep 17 00:00:00 2001 From: reaperrr Date: Sat, 13 Feb 2021 01:18:18 +0100 Subject: [PATCH] Save Mobile trait look-up in AttackBase --- OpenRA.Mods.Common/Traits/Attack/AttackBase.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/OpenRA.Mods.Common/Traits/Attack/AttackBase.cs b/OpenRA.Mods.Common/Traits/Attack/AttackBase.cs index 2563fe4e5e..7a238a3d8c 100644 --- a/OpenRA.Mods.Common/Traits/Attack/AttackBase.cs +++ b/OpenRA.Mods.Common/Traits/Attack/AttackBase.cs @@ -152,7 +152,8 @@ namespace OpenRA.Mods.Common.Traits if (!HasAnyValidWeapons(target)) return false; - var mobile = self.TraitOrDefault(); + // PERF: Mobile implements IPositionable, so we can use 'as' to save a trait look-up here. + var mobile = positionable as Mobile; if (mobile != null && !mobile.CanInteractWithGroundLayer(self)) return false;