mirror of
https://github.com/xivdev/Penumbra.git
synced 2025-12-12 10:17:22 +01:00
Use FirstOrDefault instead of manual iteration.
This commit is contained in:
parent
349b62e549
commit
90cffb1759
2 changed files with 89 additions and 95 deletions
2
Luna
2
Luna
|
|
@ -1 +1 @@
|
|||
Subproject commit 78216203f4570a6194fce9422204d8abb536c828
|
||||
Subproject commit 8fc11b993d8504982acd95b8d39e6ee7046c1347
|
||||
|
|
@ -37,17 +37,8 @@ public class ModStorage : IReadOnlyList<Mod>
|
|||
/// </summary>
|
||||
public bool TryGetMod(string identifier, [NotNullWhen(true)] out Mod? mod)
|
||||
{
|
||||
foreach (var m in Mods)
|
||||
{
|
||||
if (string.Equals(m.Identifier, identifier, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
mod = m;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
mod = null;
|
||||
return false;
|
||||
mod = this.FirstOrDefault(m => string.Equals(m.Identifier, identifier, StringComparison.OrdinalIgnoreCase));
|
||||
return mod is not null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -56,6 +47,9 @@ public class ModStorage : IReadOnlyList<Mod>
|
|||
/// </summary>
|
||||
public bool TryGetMod(string identifier, string modName, [NotNullWhen(true)] out Mod? mod)
|
||||
{
|
||||
if (modName.Length is 0)
|
||||
return TryGetMod(identifier, out mod);
|
||||
|
||||
mod = null;
|
||||
foreach (var m in Mods)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue