From e2a6b55d4443f3f352933e5815cb20591cf5e91e Mon Sep 17 00:00:00 2001 From: reaperrr Date: Sat, 20 Feb 2021 20:28:20 +0100 Subject: [PATCH] Move up Undamaged check in DamageState A mere int comparison is obviously cheaper than a comparison between two multiplications, so pulling this above the checks of other damage states allows us to bail early for undamaged actors. --- OpenRA.Mods.Common/Traits/Health.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/OpenRA.Mods.Common/Traits/Health.cs b/OpenRA.Mods.Common/Traits/Health.cs index 048f323fea..5aa80b4040 100644 --- a/OpenRA.Mods.Common/Traits/Health.cs +++ b/OpenRA.Mods.Common/Traits/Health.cs @@ -88,6 +88,9 @@ namespace OpenRA.Mods.Common.Traits { get { + if (hp == MaxHP) + return DamageState.Undamaged; + if (hp <= 0) return DamageState.Dead; @@ -100,9 +103,6 @@ namespace OpenRA.Mods.Common.Traits if (hp * 100L < MaxHP * 75L) return DamageState.Medium; - if (hp == MaxHP) - return DamageState.Undamaged; - return DamageState.Light; } }