From aef3ff6e652684d9eebdc08fe5a427e8078c05f8 Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Sun, 23 Oct 2011 11:49:33 +1300 Subject: [PATCH] remove some redundant SelectableInfo lookups --- OpenRA.Game/WorldUtils.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/OpenRA.Game/WorldUtils.cs b/OpenRA.Game/WorldUtils.cs index 11f0bd7491..3422fe0eba 100755 --- a/OpenRA.Game/WorldUtils.cs +++ b/OpenRA.Game/WorldUtils.cs @@ -117,13 +117,15 @@ namespace OpenRA public static bool HasVoice(this Actor a) { - return a.Info.Traits.Contains() && a.Info.Traits.Get().Voice != null; + var selectable = a.Info.Traits.GetOrDefault(); + return selectable != null && selectable.Voice != null; } public static VoiceInfo GetVoice(this Actor a) { - if (!a.Info.Traits.Contains()) return null; - var v = a.Info.Traits.Get().Voice; + var selectable = a.Info.Traits.GetOrDefault(); + if (selectable == null) return null; + var v = selectable.Voice; return (v == null) ? null : Rules.Voices[v]; }