From 660130653c349656a72ec679f0c1eed1cb5a5b72 Mon Sep 17 00:00:00 2001 From: abcdefg30 Date: Wed, 18 May 2022 14:16:35 +0200 Subject: [PATCH] Use TryGetValue instead of ContainsKey and a lookup for cached sounds --- OpenRA.Game/Sound/Sound.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/OpenRA.Game/Sound/Sound.cs b/OpenRA.Game/Sound/Sound.cs index 4a70cc31cf..151bc03329 100644 --- a/OpenRA.Game/Sound/Sound.cs +++ b/OpenRA.Game/Sound/Sound.cs @@ -401,9 +401,8 @@ namespace OpenRA if (!string.IsNullOrEmpty(name) && (p == null || p == p.World.LocalPlayer)) { - if (currentNotifications.ContainsKey(name)) + if (currentNotifications.TryGetValue(name, out var currentNotification)) { - var currentNotification = currentNotifications[name]; if (!currentNotification.Complete) { if (pool.AllowInterrupt) @@ -412,9 +411,8 @@ namespace OpenRA return false; } } - else if (currentSounds.ContainsKey(actorId)) + else if (currentSounds.TryGetValue(actorId, out var currentSound)) { - var currentSound = currentSounds[actorId]; if (!currentSound.Complete) { if (pool.AllowInterrupt)