From 0b55914864f225236ddbe4f4e80ad6c7eb5d2c01 Mon Sep 17 00:00:00 2001 From: Marco Carvalho Date: Sun, 7 Apr 2024 16:49:14 -0300 Subject: [PATCH] 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 --- src/Ryujinx.HLE/HOS/ModLoader.cs | 28 ++++------------------------ 1 file changed, 4 insertions(+), 24 deletions(-) diff --git a/src/Ryujinx.HLE/HOS/ModLoader.cs b/src/Ryujinx.HLE/HOS/ModLoader.cs index de9d2a5039..ee179c9290 100644 --- a/src/Ryujinx.HLE/HOS/ModLoader.cs +++ b/src/Ryujinx.HLE/HOS/ModLoader.cs @@ -173,36 +173,16 @@ namespace Ryujinx.HLE.HOS 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 modData = modMetadata.Mods.Find(x => modDir.FullName.Contains(x.Path)); + var enabled = modData?.Enabled ?? true; mods.RomfsDirs.Add(mod = new Mod(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 modData = modMetadata.Mods.Find(x => modDir.FullName.Contains(x.Path)); + var enabled = modData?.Enabled ?? true; mods.ExefsDirs.Add(mod = new Mod(dir.Name, modDir, enabled)); types.Append('E');