Invert 'if' statement to reduce nesting.

This commit is contained in:
2023-10-04 07:39:22 +01:00
parent a0a4124a26
commit 4ff79c804a
22 changed files with 447 additions and 449 deletions

View File

@@ -319,13 +319,13 @@ public class TeleDiskLzh
for(i = 0; i < T; i++)
{
if(_son[i] >= T)
{
if(_son[i] < T)
continue;
_freq[j] = (ushort)((_freq[i] + 1) / 2);
_son[j] = _son[i];
j++;
}
}
/* make a tree : first, connect children nodes */
for(i = 0, j = N_CHAR; j < T; i += 2, j++)

View File

@@ -386,15 +386,15 @@ public sealed partial class FAT
{
for(var c = 0; c < 11; c++)
{
if(rootDir[c + e] < 0x20 && rootDir[c + e] != 0x00 && rootDir[c + e] != 0x05 ||
rootDir[c + e] == 0xFF ||
rootDir[c + e] == 0x2E)
{
if((rootDir[c + e] >= 0x20 || rootDir[c + e] == 0x00 || rootDir[c + e] == 0x05) &&
rootDir[c + e] != 0xFF &&
rootDir[c + e] != 0x2E)
continue;
validRootDir = false;
break;
}
}
if(!validRootDir)
break;

View File

@@ -331,15 +331,15 @@ public sealed partial class FAT
{
for(var c = 0; c < 11; c++)
{
if(rootDir[c + e] < 0x20 && rootDir[c + e] != 0x00 && rootDir[c + e] != 0x05 ||
rootDir[c + e] == 0xFF ||
rootDir[c + e] == 0x2E)
{
if((rootDir[c + e] >= 0x20 || rootDir[c + e] == 0x00 || rootDir[c + e] == 0x05) &&
rootDir[c + e] != 0xFF &&
rootDir[c + e] != 0x2E)
continue;
validRootDir = false;
break;
}
}
if(!validRootDir)
break;

View File

@@ -126,51 +126,51 @@ public sealed partial class NintendoPlugin
for(var i = 0; i < fields.FirstPartitions.Length; i++)
{
if(offset1 + i * 8 + 8 < 0x50000)
{
if(offset1 + i * 8 + 8 >= 0x50000)
continue;
fields.FirstPartitions[i].Offset =
BigEndianBitConverter.ToUInt32(header, (int)(offset1 + i * 8 + 0)) << 2;
fields.FirstPartitions[i].Type =
BigEndianBitConverter.ToUInt32(header, (int)(offset1 + i * 8 + 4));
}
}
for(var i = 0; i < fields.SecondPartitions.Length; i++)
{
if(offset1 + i * 8 + 8 < 0x50000)
{
if(offset1 + i * 8 + 8 >= 0x50000)
continue;
fields.FirstPartitions[i].Offset =
BigEndianBitConverter.ToUInt32(header, (int)(offset2 + i * 8 + 0)) << 2;
fields.FirstPartitions[i].Type =
BigEndianBitConverter.ToUInt32(header, (int)(offset2 + i * 8 + 4));
}
}
for(var i = 0; i < fields.ThirdPartitions.Length; i++)
{
if(offset1 + i * 8 + 8 < 0x50000)
{
if(offset1 + i * 8 + 8 >= 0x50000)
continue;
fields.FirstPartitions[i].Offset =
BigEndianBitConverter.ToUInt32(header, (int)(offset3 + i * 8 + 0)) << 2;
fields.FirstPartitions[i].Type =
BigEndianBitConverter.ToUInt32(header, (int)(offset3 + i * 8 + 4));
}
}
for(var i = 0; i < fields.FourthPartitions.Length; i++)
{
if(offset1 + i * 8 + 8 < 0x50000)
{
if(offset1 + i * 8 + 8 >= 0x50000)
continue;
fields.FirstPartitions[i].Offset =
BigEndianBitConverter.ToUInt32(header, (int)(offset4 + i * 8 + 0)) << 2;
fields.FirstPartitions[i].Type =
BigEndianBitConverter.ToUInt32(header, (int)(offset4 + i * 8 + 4));
}
}
fields.Region = header[0x4E000];
fields.JapanAge = header[0x4E010];

View File

@@ -644,8 +644,8 @@ public sealed class MainWindowViewModel : ViewModelBase
foreach(string pluginName in idPlugins)
{
if(plugins.Filesystems.TryGetValue(pluginName, out pluginType))
{
if(!plugins.Filesystems.TryGetValue(pluginName, out pluginType))
continue;
if(Activator.CreateInstance(pluginType) is not IFilesystem fs)
continue;
@@ -694,7 +694,6 @@ public sealed class MainWindowViewModel : ViewModelBase
partitionModel.FileSystems.Add(filesystemModel);
}
}
}
schemeModel.Partitions.Add(partitionModel);
}
@@ -722,8 +721,8 @@ public sealed class MainWindowViewModel : ViewModelBase
foreach(string pluginName in idPlugins)
{
if(plugins.Filesystems.TryGetValue(pluginName, out pluginType))
{
if(!plugins.Filesystems.TryGetValue(pluginName, out pluginType))
continue;
if(Activator.CreateInstance(pluginType) is not IFilesystem fs)
continue;
@@ -771,7 +770,6 @@ public sealed class MainWindowViewModel : ViewModelBase
}
}
}
}
Statistics.AddMediaFormat(imageFormat.Format);
Statistics.AddMedia(imageFormat.Info.MediaType, false);

View File

@@ -772,8 +772,9 @@ public sealed partial class Alcohol120
foreach(KeyValuePair<uint, ulong> kvp in _offsetMap)
{
if(sectorAddress >= kvp.Value)
{
if(sectorAddress < kvp.Value)
continue;
foreach(Track track in _alcTracks.Values)
{
if(track.point != kvp.Key ||
@@ -786,7 +787,6 @@ public sealed partial class Alcohol120
return ReadSectors(sectorAddress - kvp.Value, length, kvp.Key, out buffer);
}
}
}
return ErrorNumber.SectorNotFound;
}
@@ -798,8 +798,9 @@ public sealed partial class Alcohol120
foreach(KeyValuePair<uint, ulong> kvp in _offsetMap)
{
if(sectorAddress >= kvp.Value)
{
if(sectorAddress < kvp.Value)
continue;
foreach(Track track in _alcTracks.Values)
{
if(track.point != kvp.Key ||
@@ -812,7 +813,6 @@ public sealed partial class Alcohol120
return ReadSectorsTag(sectorAddress - kvp.Value, length, kvp.Key, tag, out buffer);
}
}
}
return ErrorNumber.SectorNotFound;
}
@@ -1390,8 +1390,9 @@ public sealed partial class Alcohol120
foreach(KeyValuePair<uint, ulong> kvp in _offsetMap)
{
if(sectorAddress >= kvp.Value)
{
if(sectorAddress < kvp.Value)
continue;
foreach(Track alcTrack in _alcTracks.Values)
{
if(alcTrack.point != kvp.Key ||
@@ -1404,7 +1405,6 @@ public sealed partial class Alcohol120
return ReadSectorsLong(sectorAddress - kvp.Value, length, kvp.Key, out buffer);
}
}
}
return ErrorNumber.SectorNotFound;
}

View File

@@ -1010,8 +1010,9 @@ public sealed partial class CdrWin
for(var i = 0; i < cueTracks.Length; i++)
{
if(cueTracks[i].Session == s)
{
if(cueTracks[i].Session != s)
continue;
if(!firstTrackRead)
{
firstSessionTrk = i;
@@ -1023,7 +1024,6 @@ public sealed partial class CdrWin
if(i > lastSessionTrack)
lastSessionTrack = i;
}
}
if(s > 1)
{
@@ -1691,15 +1691,15 @@ public sealed partial class CdrWin
for(var s = 0; s < sessions.Length; s++)
{
if(sessions[s].Sequence > 1 &&
track.Sequence == sessions[s].StartTrack)
{
if(sessions[s].Sequence <= 1 ||
track.Sequence != sessions[s].StartTrack)
continue;
track.TrackFile.Offset += 307200;
track.Sectors -= 150;
sessions[s].StartSector = (ulong)track.Indexes[1];
}
}
}
_discImage.Sessions = sessions.ToList();

View File

@@ -127,8 +127,9 @@ public sealed partial class Dart
foreach(short l in bLength)
{
if(l != 0)
{
if(l == 0)
continue;
var buffer = new byte[BUFFER_SIZE];
if(l == -1)
@@ -163,7 +164,6 @@ public sealed partial class Dart
}
}
}
}
_dataCache = dataMs.ToArray();

View File

@@ -929,8 +929,9 @@ public sealed partial class Gdi
foreach(GdiTrack gdiTrack in _discImage.Tracks)
{
if(gdiTrack.HighDensity == expectedDensity)
{
if(gdiTrack.HighDensity != expectedDensity)
continue;
var track = new Track
{
Description = null,
@@ -952,7 +953,6 @@ public sealed partial class Gdi
tracks.Add(track);
}
}
return tracks;
}

View File

@@ -194,13 +194,13 @@ public sealed partial class PartClone
for(uint i = 0; i < length; i++)
{
if(_byteMap[sectorAddress + i] != 0)
{
if(_byteMap[sectorAddress + i] == 0)
continue;
allEmpty = false;
break;
}
}
if(allEmpty)
{

View File

@@ -445,13 +445,13 @@ public sealed partial class Partimage
for(uint i = 0; i < length; i++)
{
if((_bitmap[sectorAddress / 8] & 1 << (int)(sectorAddress % 8)) != 0)
{
if((_bitmap[sectorAddress / 8] & 1 << (int)(sectorAddress % 8)) == 0)
continue;
allEmpty = false;
break;
}
}
if(allEmpty)
{

View File

@@ -193,9 +193,10 @@ public sealed class SunDisklabel : IPartition
for(var i = 0; i < NDKMAP; i++)
{
if(dkl.dkl_map[i].dkl_cylno > 0 &&
dkl.dkl_map[i].dkl_nblk > 0)
{
if(dkl.dkl_map[i].dkl_cylno <= 0 ||
dkl.dkl_map[i].dkl_nblk <= 0)
continue;
var part = new Partition
{
Size = (ulong)dkl.dkl_map[i].dkl_nblk * DK_LABEL_SIZE,
@@ -214,7 +215,6 @@ public sealed class SunDisklabel : IPartition
partitions.Add(part);
}
}
}
else if(useDkl8)
{
var sectorsPerCylinder = (ulong)(dkl8.dkl_nsect * dkl8.dkl_nhead);
@@ -271,10 +271,11 @@ public sealed class SunDisklabel : IPartition
for(var i = 0; i < dkl8.dkl_vtoc.v_nparts; i++)
{
if(dkl8.dkl_map[i].dkl_nblk > 0 &&
dkl8.dkl_vtoc.v_part[i].p_tag != SunTag.SunEmpty &&
dkl8.dkl_vtoc.v_part[i].p_tag != SunTag.SunWholeDisk)
{
if(dkl8.dkl_map[i].dkl_nblk <= 0 ||
dkl8.dkl_vtoc.v_part[i].p_tag == SunTag.SunEmpty ||
dkl8.dkl_vtoc.v_part[i].p_tag == SunTag.SunWholeDisk)
continue;
var part = new Partition
{
Description = SunFlagsToString(dkl8.dkl_vtoc.v_part[i].p_flag),
@@ -301,7 +302,6 @@ public sealed class SunDisklabel : IPartition
partitions.Add(part);
}
}
}
else
{
AaruConsole.DebugWriteLine(MODULE_NAME, "dkl16.dkl_vtoc.v_sanity = 0x{0:X8}", dkl16.dkl_vtoc.v_sanity);
@@ -357,10 +357,11 @@ public sealed class SunDisklabel : IPartition
for(var i = 0; i < dkl16.dkl_vtoc.v_nparts; i++)
{
if(dkl16.dkl_vtoc.v_part[i].p_size > 0 &&
dkl16.dkl_vtoc.v_part[i].p_tag != SunTag.SunEmpty &&
dkl16.dkl_vtoc.v_part[i].p_tag != SunTag.SunWholeDisk)
{
if(dkl16.dkl_vtoc.v_part[i].p_size <= 0 ||
dkl16.dkl_vtoc.v_part[i].p_tag == SunTag.SunEmpty ||
dkl16.dkl_vtoc.v_part[i].p_tag == SunTag.SunWholeDisk)
continue;
var part = new Partition
{
Description = SunFlagsToString(dkl16.dkl_vtoc.v_part[i].p_flag),
@@ -387,7 +388,6 @@ public sealed class SunDisklabel : IPartition
partitions.Add(part);
}
}
}
return partitions.Count > 0;
}

View File

@@ -367,19 +367,20 @@ public sealed class VTOC : IPartition
// This means partition starts are absolute, not relative, to the VTOC position
for(var i = 0; i < V_NUMPAR; i++)
{
if(parts[i].p_tag == pTag.V_BACKUP &&
(ulong)parts[i].p_start == sectorOffset)
{
if(parts[i].p_tag != pTag.V_BACKUP ||
(ulong)parts[i].p_start != sectorOffset)
continue;
absolute = true;
break;
}
}
for(var i = 0; i < V_NUMPAR; i++)
{
if(parts[i].p_tag != pTag.V_UNUSED)
{
if(parts[i].p_tag == pTag.V_UNUSED)
continue;
var part = new Partition
{
Start = (ulong)(parts[i].p_start * bps) / imagePlugin.Info.SectorSize,
@@ -424,7 +425,6 @@ public sealed class VTOC : IPartition
if(part.End < imagePlugin.Info.Sectors)
partitions.Add(part);
}
}
return partitions.Count > 0;
}

View File

@@ -81,8 +81,9 @@ public abstract class FsExtractIssueTest
{
foreach(string pluginName in idPlugins)
{
if(plugins.ReadOnlyFilesystems.TryGetValue(pluginName, out pluginType))
{
if(!plugins.ReadOnlyFilesystems.TryGetValue(pluginName, out pluginType))
continue;
Assert.IsNotNull(pluginType, Localization.Could_not_instantiate_filesystem_plugin);
var fs = Activator.CreateInstance(pluginType) as IReadOnlyFilesystem;
@@ -100,7 +101,6 @@ public abstract class FsExtractIssueTest
ExtractFilesInDir("/", fs, Xattrs);
}
}
}
else
{
plugins.ReadOnlyFilesystems.TryGetValue(idPlugins[0], out pluginType);

View File

@@ -630,6 +630,9 @@
<s:String x:Key="/Default/CustomTools/CustomToolsData/@EntryValue"></s:String>
<s:String x:Key="/Default/Environment/Hierarchy/Build/BuildTool/CustomBuildToolPath/@EntryValue">/opt/dotnet/sdk/3.0.100/MSBuild.dll</s:String>
<s:Int64 x:Key="/Default/Environment/Hierarchy/Build/BuildTool/MsbuildVersion/@EntryValue">1048576</s:Int64>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EFeature_002EServices_002ECpp_002ECodeStyle_002EIncludesOrder_002ECppIncludeDirectiveSettingsMigration/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EFeature_002EServices_002ECpp_002ECodeStyle_002ESettingsUpgrade_002EFunctionReturnStyleSettingsUpgrader/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EFeature_002EServices_002ECpp_002ECodeStyle_002ESettingsUpgrade_002ESpaceAroundPtrSettingsUpgrader/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpKeepExistingMigration/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpPlaceEmbeddedOnSameLineMigration/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpUseContinuousIndentInsideBracesMigration/@EntryIndexedValue">True</s:Boolean>

View File

@@ -314,8 +314,9 @@ sealed class ExtractFilesCommand : Command
foreach(string pluginName in idPlugins)
{
if(plugins.ReadOnlyFilesystems.TryGetValue(pluginName, out pluginType))
{
if(!plugins.ReadOnlyFilesystems.TryGetValue(pluginName, out pluginType))
continue;
AaruConsole.WriteLine($"[bold]{string.Format(UI.As_identified_by_0, pluginType.Name)
}[/]");
@@ -346,7 +347,6 @@ sealed class ExtractFilesCommand : Command
AaruConsole.ErrorWriteLine(UI.Unable_to_mount_volume_error_0, error.ToString());
}
}
}
else
{
plugins.ReadOnlyFilesystems.TryGetValue(idPlugins[0], out pluginType);

View File

@@ -304,8 +304,8 @@ sealed class FilesystemInfoCommand : Command
foreach(string pluginName in idPlugins)
{
if(plugins.Filesystems.TryGetValue(pluginName, out pluginType))
{
if(!plugins.Filesystems.TryGetValue(pluginName, out pluginType))
continue;
if(Activator.CreateInstance(pluginType) is not IFilesystem fs)
continue;
@@ -318,7 +318,6 @@ sealed class FilesystemInfoCommand : Command
AaruConsole.Write(information);
Statistics.AddFilesystem(fsMetadata.Type);
}
}
break;
}
@@ -375,8 +374,8 @@ sealed class FilesystemInfoCommand : Command
foreach(string pluginName in idPlugins)
{
if(plugins.Filesystems.TryGetValue(pluginName, out pluginType))
{
if(!plugins.Filesystems.TryGetValue(pluginName, out pluginType))
continue;
if(Activator.CreateInstance(pluginType) is not IFilesystem fs)
continue;
@@ -388,7 +387,6 @@ sealed class FilesystemInfoCommand : Command
AaruConsole.Write(information);
Statistics.AddFilesystem(fsMetadata.Type);
}
}
break;
}

View File

@@ -286,8 +286,8 @@ sealed class LsCommand : Command
foreach(string pluginName in idPlugins)
{
if(plugins.ReadOnlyFilesystems.TryGetValue(pluginName, out pluginType))
{
if(!plugins.ReadOnlyFilesystems.TryGetValue(pluginName, out pluginType))
continue;
if(Activator.CreateInstance(pluginType) is not IReadOnlyFilesystem fs)
continue;
@@ -313,7 +313,6 @@ sealed class LsCommand : Command
AaruConsole.ErrorWriteLine(UI.Unable_to_mount_volume_error_0, error.ToString());
}
}
}
else
{
plugins.ReadOnlyFilesystems.TryGetValue(idPlugins[0], out pluginType);