Move `&&`/`||` to start of next line in main solution

This commit is contained in:
James Groom 2024-03-27 16:35:31 +00:00 committed by GitHub
parent b0ba7a1246
commit 8967f58df8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
16 changed files with 41 additions and 65 deletions

View File

@ -279,10 +279,9 @@ namespace BizHawk.BizInvoke
private static void VerifyParameter(Type type)
{
if (type == typeof(float) || type == typeof(double) ||
type == typeof(void) || type.IsPrimitive || type.IsEnum ||
type.IsPointer || typeof(Delegate).IsAssignableFrom(type) ||
type.IsByRef || type.IsClass)
if (type.IsPrimitive || type.IsEnum || type.IsPointer || type.IsByRef || type.IsClass
|| type == typeof(float) || type == typeof(double) || type == typeof(void) //TODO aren't these covered by IsPrimitive? --yoshi
|| typeof(Delegate).IsAssignableFrom(type))
{
return;
}

View File

@ -88,8 +88,7 @@ namespace BizHawk.Bizware.Audio
try
{
var status = (BufferStatus)_deviceBuffer.Status;
return (status & BufferStatus.BufferLost) == 0 &&
(status & BufferStatus.Playing) == BufferStatus.Playing;
return (status & (BufferStatus.BufferLost | BufferStatus.Playing)) is BufferStatus.Playing;
}
catch (SharpDXException)
{
@ -290,8 +289,7 @@ namespace BizHawk.Bizware.Audio
}
var status = (BufferStatus)_wavDeviceBuffer.Status;
return (status & BufferStatus.BufferLost) == 0 &&
(status & BufferStatus.Playing) == BufferStatus.Playing;
return (status & (BufferStatus.BufferLost | BufferStatus.Playing)) is BufferStatus.Playing;
}
}

View File

@ -32,11 +32,11 @@ namespace BizHawk.Bizware.Graphics
// set some sensible defaults
SDL_GL_ResetAttributes();
if (SDL_GL_SetAttribute(SDL_GLattr.SDL_GL_RED_SIZE, 8) != 0 ||
SDL_GL_SetAttribute(SDL_GLattr.SDL_GL_GREEN_SIZE, 8) != 0 ||
SDL_GL_SetAttribute(SDL_GLattr.SDL_GL_BLUE_SIZE, 8) != 0 ||
SDL_GL_SetAttribute(SDL_GLattr.SDL_GL_ALPHA_SIZE, 0) != 0 ||
SDL_GL_SetAttribute(SDL_GLattr.SDL_GL_DOUBLEBUFFER, 1) != 0)
if (SDL_GL_SetAttribute(SDL_GLattr.SDL_GL_RED_SIZE, 8) is not 0
|| SDL_GL_SetAttribute(SDL_GLattr.SDL_GL_GREEN_SIZE, 8) is not 0
|| SDL_GL_SetAttribute(SDL_GLattr.SDL_GL_BLUE_SIZE, 8) is not 0
|| SDL_GL_SetAttribute(SDL_GLattr.SDL_GL_ALPHA_SIZE, 0) is not 0
|| SDL_GL_SetAttribute(SDL_GLattr.SDL_GL_DOUBLEBUFFER, 1) is not 0)
{
throw new($"Could not set GL attributes! SDL Error: {SDL_GetError()}");
}

View File

@ -56,9 +56,7 @@ namespace BizHawk.Bizware.Input
lock (_lockObj)
{
if (_keyboard == null ||
_keyboard.Acquire().Failure ||
_keyboard.Poll().Failure)
if (_keyboard is null || _keyboard.Acquire().Failure || _keyboard.Poll().Failure)
{
return Enumerable.Empty<KeyEvent>();
}

View File

@ -85,8 +85,8 @@ namespace BizHawk.Bizware.Input
return DefWindowProcW(hWnd, uMsg, wParam, lParam);
}
if (input->header.dwType == RAWINPUTHEADER.RIM_TYPE.KEYBOARD &&
(input->data.keyboard.Flags & ~(RAWKEYBOARD.RI_KEY.E0 | RAWKEYBOARD.RI_KEY.BREAK)) == 0)
if (input->header.dwType is RAWINPUTHEADER.RIM_TYPE.KEYBOARD
&& (input->data.keyboard.Flags & ~(RAWKEYBOARD.RI_KEY.E0 | RAWKEYBOARD.RI_KEY.BREAK)) is 0)
{
var handle = GCHandle.FromIntPtr(ud);
var rawKeyInput = (RawKeyInput)handle.Target;

View File

@ -238,8 +238,8 @@ namespace BizHawk.Client.Common.FilterManager
{
newTarget = true;
}
else if (currState.SurfaceDisposition == SurfaceDisposition.Texture &&
iosi.SurfaceDisposition == SurfaceDisposition.RenderTarget)
else if (currState.SurfaceDisposition is SurfaceDisposition.Texture
&& iosi.SurfaceDisposition is SurfaceDisposition.RenderTarget)
{
newTarget = true;
}

View File

@ -105,8 +105,7 @@ namespace BizHawk.Client.Common
{
RomData = FileData;
}
else if (file.Extension == ".dsk" || file.Extension == ".tap" || file.Extension == ".tzx" ||
file.Extension == ".pzx" || file.Extension == ".csw" || file.Extension == ".wav" || file.Extension == ".cdt")
else if (file.Extension is ".cdt" or ".csw" or ".dsk" or ".pzx" or ".tap" or ".tzx" or ".wav")
{
// these are not roms. unfortunately if treated as such there are certain edge-cases
// where a header offset is detected. This should mitigate this issue until a cleaner solution is found

View File

@ -239,8 +239,8 @@ namespace BizHawk.Client.Common
UpdateHistory(_baseSamplesPerFrame, count, BaseSampleRateMaxHistoryLength);
if (_baseSamplesPerFrame.Count >= BaseSampleRateUsableHistoryLength &&
!_baseEmptyFrameCorrectionHistory.Any(n => n))
if (_baseSamplesPerFrame.Count >= BaseSampleRateUsableHistoryLength
&& !_baseEmptyFrameCorrectionHistory.Contains(true))
{
double baseAverageSamplesPerFrame = _baseSamplesPerFrame.Average();
if (baseAverageSamplesPerFrame != 0.0)

View File

@ -115,8 +115,9 @@ namespace BizHawk.Client.Common
{
try
{
if (DebuggableCore != null && DebuggableCore.MemoryCallbacksAvailable() &&
DebuggableCore.MemoryCallbacks.ExecuteCallbacksAvailable)
if (DebuggableCore is not null
&& DebuggableCore.MemoryCallbacksAvailable()
&& DebuggableCore.MemoryCallbacks.ExecuteCallbacksAvailable)
{
if (!HasScope(scope))
{

View File

@ -160,12 +160,14 @@ namespace BizHawk.Client.Common
{
long targetSize = settings.BufferSize * 1024 * 1024;
long size = 1L << (int)Math.Floor(Math.Log(targetSize, 2));
return Size == size &&
_useCompression == settings.UseCompression &&
_fixedRewindInterval == settings.UseFixedRewindInterval &&
(_fixedRewindInterval ? _targetRewindInterval == settings.TargetRewindInterval : _targetFrameLength == settings.TargetFrameLength) &&
_allowOutOfOrderStates == settings.AllowOutOfOrderStates &&
_backingStoreType == settings.BackingStore;
return Size == size
&& _useCompression == settings.UseCompression
&& _fixedRewindInterval == settings.UseFixedRewindInterval
&& (_fixedRewindInterval
? _targetRewindInterval == settings.TargetRewindInterval
: _targetFrameLength == settings.TargetFrameLength)
&& _allowOutOfOrderStates == settings.AllowOutOfOrderStates
&& _backingStoreType == settings.BackingStore;
}
private bool ShouldCaptureForFrameDiff(int frameDiff)

View File

@ -224,8 +224,7 @@ namespace BizHawk.Client.Common
case WatchSize.Word:
return addr == _watch.Address || addr == _watch.Address + 1;
case WatchSize.DWord:
return addr == _watch.Address || addr == _watch.Address + 1 ||
addr == _watch.Address + 2 || addr == _watch.Address + 3;
return addr >= _watch.Address && addr <= _watch.Address + 3;
}
}

View File

@ -324,16 +324,8 @@ namespace BizHawk.Client.Common
/// <param name="other">The <see cref="Watch"/> to compare</param>
/// <returns>True if both object are equals; otherwise, false</returns>
public bool Equals(Watch other)
{
if (other is null)
{
return false;
}
return _domain == other._domain &&
Address == other.Address &&
Size == other.Size;
}
=> other is not null
&& _domain == other._domain && Address == other.Address && Size == other.Size;
/// <summary>
/// Determines if this <see cref="Watch"/> is equals to an instance of <see cref="Cheat"/>

View File

@ -89,13 +89,7 @@ namespace BizHawk.Common.CollectionExtensions
return midItem;
}
}
if (min == max &&
keySelector(list[min]).CompareTo(key) == 0)
{
return list[min];
}
if (min == max && keySelector(list[min]).CompareTo(key) is 0) return list[min];
throw new InvalidOperationException("Item not found");
}

View File

@ -207,9 +207,9 @@ namespace BizHawk.Emulation.Common
}
}
if (trk.Sectors[0].SectorData[7] == 3 &&
trk.Sectors[0].SectorData[9] == 23 &&
trk.Sectors[0].SectorData[2] == 40)
if (trk.Sectors[0].SectorData[7] is 3
&& trk.Sectors[0].SectorData[9] is 23
&& trk.Sectors[0].SectorData[2] is 40)
{
IdentifiedSystem = VSystemID.Raw.ZXSpectrum;
return;

View File

@ -481,8 +481,8 @@ namespace BizHawk.Emulation.DiscSystem
var (dir, fileNoExt, _) = aFile.MDSPath.SplitPathToDirFileAndExt();
if (f.FilenameOffset == 0 ||
string.Equals(fileName, "*.mdf", StringComparison.OrdinalIgnoreCase))
if (f.FilenameOffset is 0
|| string.Equals(fileName, "*.mdf", StringComparison.OrdinalIgnoreCase))
{
fileName = $@"{dir}\{fileNoExt}.mdf";
}

View File

@ -415,9 +415,7 @@ namespace BizHawk.Emulation.DiscSystem
var v2 = chunkID == "DAOX";
var ntracks = ret.LastTrack - ret.FirstTrack + 1;
if (ntracks <= 0 ||
ret.FirstTrack is < 0 or > 99 ||
ret.LastTrack is < 0 or > 99)
if (ntracks <= 0 || ret.FirstTrack is < 0 or > 99 || ret.LastTrack is < 0 or > 99)
{
throw new NRGParseException("Malformed NRG format: Corrupt track numbers in DAO chunk!");
}
@ -443,9 +441,7 @@ namespace BizHawk.Emulation.DiscSystem
track.TrackStartFileOffset = BinaryPrimitives.ReadInt64BigEndian(chunkData.Slice(i + 26, sizeof(long)));
track.TrackEndFileOffset = BinaryPrimitives.ReadInt64BigEndian(chunkData.Slice(i + 34, sizeof(long)));
if (track.PregapFileOffset < 0 ||
track.TrackStartFileOffset < 0 ||
track.TrackEndFileOffset < 0)
if (track.PregapFileOffset < 0 || track.TrackStartFileOffset < 0 || track.TrackEndFileOffset < 0)
{
throw new NRGParseException("Malformed NRG format: Negative file offsets in DAOX chunk!");
}
@ -849,9 +845,7 @@ namespace BizHawk.Emulation.DiscSystem
if (nrgf.DAOTrackInfos.Count > 0)
{
if (nrgf.TAOTrackInfos.Count > 0 ||
nrgf.RELOs.Count > 0 ||
nrgf.TOCTs.Count > 0)
if (nrgf.TAOTrackInfos.Count is not 0 || nrgf.RELOs.Count is not 0 || nrgf.TOCTs.Count is not 0)
{
throw new NRGParseException("Malformed NRG format: DAO and TAO chunks both present on file!");
}