Replacing the try-catch block with null-conditional and null-coalescing operators (#6612)

* Replacing the try-catch block with null-conditional and null-coalescing operators

* repeating
This commit is contained in:
Marco Carvalho 2024-04-07 16:49:14 -03:00 committed by GitHub
parent 451a28afb8
commit 0b55914864
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -172,37 +172,17 @@ namespace Ryujinx.HLE.HOS
Mod<DirectoryInfo> mod = new("", null, true);
if (StrEquals(RomfsDir, modDir.Name))
{
bool enabled;
try
{
var modData = modMetadata.Mods.Find(x => modDir.FullName.Contains(x.Path));
enabled = modData.Enabled;
}
catch
{
// Mod is not in the list yet. New mods should be enabled by default.
enabled = true;
}
var enabled = modData?.Enabled ?? true;
mods.RomfsDirs.Add(mod = new Mod<DirectoryInfo>(dir.Name, modDir, enabled));
types.Append('R');
}
else if (StrEquals(ExefsDir, modDir.Name))
{
bool enabled;
try
{
var modData = modMetadata.Mods.Find(x => modDir.FullName.Contains(x.Path));
enabled = modData.Enabled;
}
catch
{
// Mod is not in the list yet. New mods should be enabled by default.
enabled = true;
}
var enabled = modData?.Enabled ?? true;
mods.ExefsDirs.Add(mod = new Mod<DirectoryInfo>(dir.Name, modDir, enabled));
types.Append('E');