From fe5bacfdc2ba0f7b94f47413fed344062489a844 Mon Sep 17 00:00:00 2001 From: Misa Date: Sun, 3 Jan 2021 23:22:00 -0800 Subject: [PATCH] Invert currentsong check and un-nest rest of function This removes an indentation level, and makes it easier to reason about the function since you essentially now view it as the function returning right there. --- desktop_version/src/Music.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/desktop_version/src/Music.cpp b/desktop_version/src/Music.cpp index bd78cb39..107b4a31 100644 --- a/desktop_version/src/Music.cpp +++ b/desktop_version/src/Music.cpp @@ -188,8 +188,11 @@ void musicclass::play(int t, const double position_sec /*= 0.0*/, const int fade safeToProcessMusic = true; musicVolume = MIX_MAX_VOLUME; - if (currentsong != t) + if (currentsong == t) { + return; + } + if (t != -1) { currentsong = t; @@ -239,7 +242,6 @@ void musicclass::play(int t, const double position_sec /*= 0.0*/, const int fade { currentsong = -1; } - } } void musicclass::resume(const int fadein_ms /*= 0*/)