Skip to content

Commit c2d5a9c

Browse files
committed
Banish empty conditional blocks
1 parent 84d2866 commit c2d5a9c

File tree

10 files changed

+25
-34
lines changed

10 files changed

+25
-34
lines changed

src/BizHawk.Bizware.OpenTK3/IGL_TK.cs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -618,15 +618,10 @@ public Matrix4 CreateGuiViewMatrix(sd.Size dims, bool autoflip)
618618
ret.Row1.Y = -1.0f;
619619
ret.Row3.X = -(float)dims.Width * 0.5f;
620620
ret.Row3.Y = (float)dims.Height * 0.5f;
621-
if (autoflip)
621+
if (autoflip && _currRenderTarget is not null) // flip as long as we're not a final render target
622622
{
623-
if (_currRenderTarget == null) { }
624-
else
625-
{
626-
//flip as long as we're not a final render target
627-
ret.Row1.Y = 1.0f;
628-
ret.Row3.Y *= -1;
629-
}
623+
ret.Row1.Y = 1.0f;
624+
ret.Row3.Y *= -1;
630625
}
631626
return ret;
632627
}

src/BizHawk.Client.EmuHawk/AVOut/AviWriter.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -333,9 +333,7 @@ public void PopulateWAVEFORMATEX(ref AVIWriterImports.WAVEFORMATEX wfex)
333333
if (a_bits == 16) bytes = 2;
334334
else if (a_bits == 8) bytes = 1;
335335
else throw new InvalidOperationException($"only 8/16 bits audio are supported by {nameof(AviWriter)} and you chose: {a_bits}");
336-
if (a_channels == 1) { }
337-
else if (a_channels == 2) { }
338-
else throw new InvalidOperationException($"only 1/2 channels audio are supported by {nameof(AviWriter)} and you chose: {a_channels}");
336+
if (a_channels is not (1 or 2)) throw new InvalidOperationException($"only 1/2 channels audio are supported by {nameof(AviWriter)} and you chose: {a_channels}");
339337
wfex.Init();
340338
wfex.nBlockAlign = (ushort)(bytes * a_channels);
341339
wfex.nChannels = (ushort)a_channels;

src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -605,9 +605,7 @@ private void StartNewTasMovie()
605605
MovieSession.SetMovieController(Emulator.ControllerDefinition); // hack, see interface comment
606606
tasMovie.ClearChanges(); // Don't ask to save changes here.
607607
tasMovie.Save();
608-
if (HandleMovieLoadStuff(tasMovie))
609-
{
610-
}
608+
_ = HandleMovieLoadStuff(tasMovie);
611609
// let's not keep this longer than we actually need
612610
// the user will be prompted to enter a proper name
613611
// when they want to save

src/BizHawk.Emulation.Cores/Computers/AmstradCPC/Hardware/Disk/NECUPD765.FDC.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -637,8 +637,10 @@ private void UPD_ReadDeletedData()
637637

638638
int buffPos = 0;
639639
int sectorSize = 0;
640+
#pragma warning disable CS0219
640641
int maxTransferCap = 0;
641-
if (maxTransferCap > 0) { }
642+
// if (maxTransferCap > 0) { }
643+
#pragma warning restore CS0219
642644

643645
// calculate requested size of data required
644646
if (ActiveCommandParams.SectorSize == 0)
@@ -950,8 +952,8 @@ private void UPD_ReadDiagnostic()
950952

951953
int buffPos = 0;
952954
int sectorSize = 0;
953-
int maxTransferCap = 0;
954-
if (maxTransferCap > 0) { }
955+
int maxTransferCap = 0; // why doesn't this get flagged for CS0219?
956+
// if (maxTransferCap > 0) { }
955957

956958
// calculate requested size of data required
957959
if (ActiveCommandParams.SectorSize == 0)

src/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Hardware/Disk/NECUPD765.FDC.cs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -337,8 +337,10 @@ private void UPD_ReadData()
337337
}
338338

339339
int buffPos = 0;
340-
int sectorSize = 0;
340+
int sectorSize = 0; // why doesn't this get flagged for CS0219?
341+
#pragma warning disable CS0219
341342
int maxTransferCap = 0;
343+
#pragma warning restore CS0219
342344

343345
// calculate requested size of data required
344346
if (ActiveCommandParams.SectorSize == 0)
@@ -353,7 +355,7 @@ private void UPD_ReadData()
353355
if (!CMD_FLAG_MF)
354356
maxTransferCap = 3328;
355357

356-
if (maxTransferCap == 0) { }
358+
// if (maxTransferCap is 0) { }
357359
}
358360
else
359361
{
@@ -646,8 +648,10 @@ private void UPD_ReadDeletedData()
646648

647649
int buffPos = 0;
648650
int sectorSize = 0;
651+
#pragma warning disable CS0219
649652
int maxTransferCap = 0;
650-
if (maxTransferCap > 0) { }
653+
// if (maxTransferCap > 0) { }
654+
#pragma warning restore CS0219
651655

652656
// calculate requested size of data required
653657
if (ActiveCommandParams.SectorSize == 0)
@@ -959,8 +963,10 @@ private void UPD_ReadDiagnostic()
959963

960964
int buffPos = 0;
961965
int sectorSize = 0;
966+
#pragma warning disable CS0219
962967
int maxTransferCap = 0;
963-
if (maxTransferCap > 0) { }
968+
// if (maxTransferCap > 0) { }
969+
#pragma warning restore CS0219
964970

965971
// calculate requested size of data required
966972
if (ActiveCommandParams.SectorSize == 0)

src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Namcot1xx/Mapper088.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,7 @@ public override byte ReadPpu(int addr)
5858
}
5959
public override void WritePpu(int addr, byte value)
6060
{
61-
if (addr < 0x2000) { }
62-
else base.WritePpu(addr, value);
61+
if (addr >= 0x2000) base.WritePpu(addr, value);
6362
}
6463
}
6564
}

src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Namcot1xx/Mapper112.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,7 @@ public override byte ReadPpu(int addr)
134134
}
135135
public override void WritePpu(int addr, byte value)
136136
{
137-
if (addr < 0x2000) { }
138-
else base.WritePpu(addr, value);
137+
if (addr >= 0x2000) base.WritePpu(addr, value);
139138
}
140139

141140
public override byte ReadPrg(int addr)

src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Namcot1xx/Mapper154.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,7 @@ public override byte ReadPpu(int addr)
4747
}
4848
public override void WritePpu(int addr, byte value)
4949
{
50-
if (addr < 0x2000) { }
51-
else base.WritePpu(addr, value);
50+
if (addr >= 0x2000) base.WritePpu(addr, value);
5251
}
5352

5453
public override void WritePrg(int addr, byte value)

src/BizHawk.Emulation.DiscSystem/DiscFormats/CUE/CUE_Compile.cs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -288,12 +288,7 @@ private void OpenFile(CUE_File.Command.FILE f)
288288

289289
private void CreateTrack1Pregap()
290290
{
291-
if (OUT_CompiledCueTracks[1].PregapLength.Sector == 0) { }
292-
else if (OUT_CompiledCueTracks[1].PregapLength.Sector == 150) { }
293-
else
294-
{
295-
Error("Track 1 specified an illegal pregap. It's being ignored and replaced with a 00:02:00 pregap");
296-
}
291+
if (OUT_CompiledCueTracks[1].PregapLength.Sector is not (0 or 150)) Error("Track 1 specified an illegal pregap. It's being ignored and replaced with a 00:02:00 pregap");
297292
OUT_CompiledCueTracks[1].PregapLength = new Timestamp(150);
298293
}
299294

src/BizHawk.Emulation.DiscSystem/Internal/Jobs/Synthesize_DiscTOC_From_RawTOCEntries_Job.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public void Run()
7979

8080
//this is speculative:
8181
//well, nothing to be done here..
82-
if (ret.FirstRecordedTrackNumber == -1) { }
82+
// if (ret.FirstRecordedTrackNumber == -1) { }
8383
if (ret.LastRecordedTrackNumber == -1) { ret.LastRecordedTrackNumber = maxFoundTrack; }
8484
if (ret.Session1Format == SessionFormat.None) ret.Session1Format = SessionFormat.Type00_CDROM_CDDA;
8585

0 commit comments

Comments
 (0)