Emulation.DiscSystem -> simplify if/elses into return statements

This commit is contained in:
adelikat 2020-02-26 14:51:05 -06:00
parent cd9103b412
commit 3f9b93be59
4 changed files with 8 additions and 20 deletions

View File

@ -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)

View File

@ -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());
}
}
}

View File

@ -127,14 +127,7 @@ namespace BizHawk.Emulation.DiscSystem
/// <summary>
/// The string representation of the MSF
/// </summary>
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;

View File

@ -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);
}
}