Refactor `yield`ing methods to direct, stateless returns

This commit is contained in:
YoshiRulz 2024-07-12 10:30:32 +10:00
parent 166f1d537e
commit dfe8b1308c
No known key found for this signature in database
GPG Key ID: C4DE31C245353FB7
8 changed files with 35 additions and 62 deletions

View File

@ -72,14 +72,14 @@ namespace BizHawk.Client.Common
=> new(sysID, "Cheats", Path.Combine(".", "Cheats"));
private static IEnumerable<PathEntry> CommonEntriesFor(string sysID, string basePath, bool omitSaveRAM = false)
{
yield return BaseEntryFor(sysID, basePath);
yield return ROMEntryFor(sysID);
yield return SavestatesEntryFor(sysID);
if (!omitSaveRAM) yield return SaveRAMEntryFor(sysID);
yield return ScreenshotsEntryFor(sysID);
yield return CheatsEntryFor(sysID);
}
=> [
BaseEntryFor(sysID, basePath),
ROMEntryFor(sysID),
SavestatesEntryFor(sysID),
..(omitSaveRAM ? [ ] : new[] { SaveRAMEntryFor(sysID) }),
ScreenshotsEntryFor(sysID),
CheatsEntryFor(sysID),
];
public static string GetDisplayNameFor(string sysID)
=> _displayNameLookup.GetValueOrPut(sysID, static s => s + " (INTERIM)");

View File

@ -35,16 +35,12 @@ namespace BizHawk.Client.Common
/// <summary>
/// Gets an enumeration of <see cref="WatchDisplayType"/> that are valid for a <see cref="ByteWatch"/>
/// </summary>
public static IEnumerable<WatchDisplayType> ValidTypes
{
get
{
yield return WatchDisplayType.Unsigned;
yield return WatchDisplayType.Signed;
yield return WatchDisplayType.Hex;
yield return WatchDisplayType.Binary;
}
}
public static IEnumerable<WatchDisplayType> ValidTypes { get; } = [
WatchDisplayType.Unsigned,
WatchDisplayType.Signed,
WatchDisplayType.Hex,
WatchDisplayType.Binary,
];
/// <summary>
/// Get a list a <see cref="WatchDisplayType"/> that can be used for this <see cref="ByteWatch"/>

View File

@ -36,19 +36,15 @@ namespace BizHawk.Client.Common
/// <summary>
/// Gets a list of <see cref="WatchDisplayType"/> for a <see cref="DWordWatch"/>
/// </summary>
public static IEnumerable<WatchDisplayType> ValidTypes
{
get
{
yield return WatchDisplayType.Unsigned;
yield return WatchDisplayType.Signed;
yield return WatchDisplayType.Hex;
yield return WatchDisplayType.Binary;
yield return WatchDisplayType.FixedPoint_20_12;
yield return WatchDisplayType.FixedPoint_16_16;
yield return WatchDisplayType.Float;
}
}
public static IEnumerable<WatchDisplayType> ValidTypes { get; } = [
WatchDisplayType.Unsigned,
WatchDisplayType.Signed,
WatchDisplayType.Hex,
WatchDisplayType.Binary,
WatchDisplayType.FixedPoint_20_12,
WatchDisplayType.FixedPoint_16_16,
WatchDisplayType.Float,
];
/// <summary>
/// Get a list of <see cref="WatchDisplayType"/> that can be used for a <see cref="DWordWatch"/>

View File

@ -34,9 +34,7 @@ namespace BizHawk.Client.Common
/// </summary>
/// <returns>WatchDisplayType.Separator nothing else</returns>
public override IEnumerable<WatchDisplayType> AvailableTypes()
{
yield return WatchDisplayType.Separator;
}
=> [ WatchDisplayType.Separator ];
/// <summary>
/// Ignore that stuff

View File

@ -35,17 +35,13 @@ namespace BizHawk.Client.Common
/// <summary>
/// Gets an Enumeration of <see cref="WatchDisplayType"/>s that are valid for a <see cref="WordWatch"/>
/// </summary>
public static IEnumerable<WatchDisplayType> ValidTypes
{
get
{
yield return WatchDisplayType.Unsigned;
yield return WatchDisplayType.Signed;
yield return WatchDisplayType.Hex;
yield return WatchDisplayType.Binary;
yield return WatchDisplayType.FixedPoint_12_4;
}
}
public static IEnumerable<WatchDisplayType> ValidTypes { get; } = [
WatchDisplayType.Unsigned,
WatchDisplayType.Signed,
WatchDisplayType.Hex,
WatchDisplayType.Binary,
WatchDisplayType.FixedPoint_12_4,
];
/// <summary>
/// Get a list a <see cref="WatchDisplayType"/> that can be used for this <see cref="WordWatch"/>

View File

@ -977,8 +977,7 @@ namespace BizHawk.Client.EmuHawk
public IEnumerable<ToolStripItem> GenerateContextMenuItems()
{
if (!Rotatable) yield break;
yield return new ToolStripSeparator();
if (!Rotatable) return [ ];
var rotate = new ToolStripMenuItem
{
Name = "RotateMenuItem",
@ -986,7 +985,7 @@ namespace BizHawk.Client.EmuHawk
ShortcutKeyDisplayString = RotateHotkeyStr
};
rotate.Click += (_, _) => HorizontalOrientation = !HorizontalOrientation;
yield return rotate;
return [ new ToolStripSeparator(), rotate ];
}
public string RotateHotkeyStr => "Ctrl+Shift+F";

View File

@ -10,13 +10,7 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64
private IDebuggable _selectedDebuggable;
private IEnumerable<IDebuggable> GetAvailableDebuggables()
{
yield return _board.Cpu;
if (_board.DiskDrive != null)
{
yield return _board.DiskDrive;
}
}
=> _board.DiskDrive is IDebuggable dd ? [ _board.Cpu, dd ] : [ _board.Cpu ];
private void SetDefaultDebuggable()
{

View File

@ -10,13 +10,7 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64
private IDisassemblable _selectedDisassemblable;
private IEnumerable<IDisassemblable> GetAvailableDisassemblables()
{
yield return _board.Cpu;
if (_board.DiskDrive != null)
{
yield return _board.DiskDrive;
}
}
=> _board.DiskDrive is IDisassemblable dd ? [ _board.Cpu, dd ] : [ _board.Cpu ];
private void SetDefaultDisassemblable()
{