Remove superflous null checks

and cache a dictionary lookup.
This commit is contained in:
Matthias Mailänder
2021-12-13 20:03:32 +01:00
committed by abcdefg30
parent eb4de47362
commit 718bf88b9a

View File

@@ -395,7 +395,7 @@ namespace OpenRA
if (currentNotifications.ContainsKey(name)) if (currentNotifications.ContainsKey(name))
{ {
var currentNotification = currentNotifications[name]; var currentNotification = currentNotifications[name];
if (currentNotification != null && !currentNotification.Complete) if (!currentNotification.Complete)
{ {
if (pool.AllowInterrupt) if (pool.AllowInterrupt)
soundEngine.StopSound(currentNotification); soundEngine.StopSound(currentNotification);
@@ -403,12 +403,16 @@ namespace OpenRA
return false; return false;
} }
} }
else if (currentSounds.ContainsKey(actorId) && !currentSounds[actorId].Complete) else if (currentSounds.ContainsKey(actorId))
{ {
if (pool.AllowInterrupt) var currentSound = currentSounds[actorId];
soundEngine.StopSound(currentSounds[actorId]); if (!currentSound.Complete)
else {
return false; if (pool.AllowInterrupt)
soundEngine.StopSound(currentSound);
else
return false;
}
} }
var volume = InternalSoundVolume * volumeModifier * pool.VolumeModifier; var volume = InternalSoundVolume * volumeModifier * pool.VolumeModifier;