Skip to content

Commit

Permalink
Use TryGetValue instead of ContainsKey and a lookup for cached sounds
Browse files Browse the repository at this point in the history
  • Loading branch information
abcdefg30 authored and atlimit8 committed May 22, 2022
1 parent ea04a7f commit 6601306
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions OpenRA.Game/Sound/Sound.cs
Expand Up @@ -401,9 +401,8 @@ public float VideoVolume

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)
Expand All @@ -412,9 +411,8 @@ public float VideoVolume
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)
Expand Down

0 comments on commit 6601306

Please sign in to comment.