From 3f9b93be59e3295336a55c01490316cf151e6a30 Mon Sep 17 00:00:00 2001 From: adelikat Date: Wed, 26 Feb 2020 14:51:05 -0600 Subject: [PATCH] Emulation.DiscSystem -> simplify if/elses into return statements --- BizHawk.Emulation.DiscSystem/DiscFormats/M3U_file.cs | 4 +--- BizHawk.Emulation.DiscSystem/DiscIdentifier.cs | 8 ++++---- BizHawk.Emulation.DiscSystem/DiscTypes.cs | 9 +-------- BizHawk.Emulation.DiscSystem/Internal/SectorSynth.cs | 7 ++----- 4 files changed, 8 insertions(+), 20 deletions(-) diff --git a/BizHawk.Emulation.DiscSystem/DiscFormats/M3U_file.cs b/BizHawk.Emulation.DiscSystem/DiscFormats/M3U_file.cs index 7a321c407a..d8490f3853 100644 --- a/BizHawk.Emulation.DiscSystem/DiscFormats/M3U_file.cs +++ b/BizHawk.Emulation.DiscSystem/DiscFormats/M3U_file.cs @@ -8,9 +8,7 @@ namespace BizHawk.Emulation.DiscSystem public static M3U_File Read(StreamReader sr) { M3U_File ret = new M3U_File(); - if (!ret.Parse(sr)) - return null; - else return ret; + return !ret.Parse(sr) ? null : ret; } bool Parse(StreamReader sr) diff --git a/BizHawk.Emulation.DiscSystem/DiscIdentifier.cs b/BizHawk.Emulation.DiscSystem/DiscIdentifier.cs index fffb108d72..8e7e0d30ff 100644 --- a/BizHawk.Emulation.DiscSystem/DiscIdentifier.cs +++ b/BizHawk.Emulation.DiscSystem/DiscIdentifier.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Text; //disc type identification logic @@ -175,8 +176,8 @@ namespace BizHawk.Emulation.DiscSystem //its a cheap win for a lot of systems, but ONLY if the iso.Parse() method is quick running (might have to time it) if (isIso) { - var appId = System.Text.Encoding.ASCII.GetString(iso.VolumeDescriptors[0].ApplicationIdentifier).TrimEnd('\0', ' '); - var sysId = System.Text.Encoding.ASCII.GetString(iso.VolumeDescriptors[0].SystemIdentifier).TrimEnd('\0', ' '); + var appId = Encoding.ASCII.GetString(iso.VolumeDescriptors[0].ApplicationIdentifier).TrimEnd('\0', ' '); + var sysId = Encoding.ASCII.GetString(iso.VolumeDescriptors[0].SystemIdentifier).TrimEnd('\0', ' '); //for example: PSX magical drop F (JP SLPS_02337) doesn't have the correct iso PVD fields //but, some PSX games (junky rips) don't have the 'licensed by string' so we'll hope they get caught here @@ -365,8 +366,7 @@ namespace BizHawk.Emulation.DiscSystem private bool SectorContains(string s, int lba = 0) { var data = ReadSectorCached(lba); - if (data == null) return false; - return System.Text.Encoding.ASCII.GetString(data).ToLower().Contains(s.ToLower()); + return data != null && Encoding.ASCII.GetString(data).ToLower().Contains(s.ToLower()); } } } \ No newline at end of file diff --git a/BizHawk.Emulation.DiscSystem/DiscTypes.cs b/BizHawk.Emulation.DiscSystem/DiscTypes.cs index 53d2ee8dd0..1e6d2178b8 100644 --- a/BizHawk.Emulation.DiscSystem/DiscTypes.cs +++ b/BizHawk.Emulation.DiscSystem/DiscTypes.cs @@ -127,14 +127,7 @@ namespace BizHawk.Emulation.DiscSystem /// /// The string representation of the MSF /// - public string Value - { - get - { - if (!Valid) return "--:--:--"; - return $"{(Negative ? '-' : '+')}{MIN:D2}:{SEC:D2}:{FRAC:D2}"; - } - } + public string Value => !Valid ? "--:--:--" : $"{(Negative ? '-' : '+')}{MIN:D2}:{SEC:D2}:{FRAC:D2}"; public readonly byte MIN, SEC, FRAC; public readonly bool Valid, Negative; diff --git a/BizHawk.Emulation.DiscSystem/Internal/SectorSynth.cs b/BizHawk.Emulation.DiscSystem/Internal/SectorSynth.cs index 3ee0764023..418559a70b 100644 --- a/BizHawk.Emulation.DiscSystem/Internal/SectorSynth.cs +++ b/BizHawk.Emulation.DiscSystem/Internal/SectorSynth.cs @@ -133,8 +133,7 @@ namespace BizHawk.Emulation.DiscSystem { int index = lba - FirstLBA; if (index < 0) return null; - if (index >= Sectors.Count) return null; - return Sectors[index]; + return index >= Sectors.Count ? null : Sectors[index]; } } @@ -165,9 +164,7 @@ namespace BizHawk.Emulation.DiscSystem } public ISectorSynthJob2448 Get(int lba) { - if (Condition(lba)) - return Patch; - else return Parent.Get(lba); + return Condition(lba) ? Patch : Parent.Get(lba); } }