Introduce FirstOrDefault extensions method for Array.Find and List.Find.

This allows the LINQ spelling to be used, but benefits from the performance improvement of the specific methods for these classes that provide the same result.
This commit is contained in:
RoosterDragon
2023-11-17 09:49:27 +00:00
committed by Gustas
parent acca837142
commit e6914f707a
54 changed files with 83 additions and 89 deletions

View File

@@ -305,7 +305,7 @@ namespace OpenRA.Mods.Common.Traits
// HACK: Use of this function requires that there is one squad of this type.
Squad GetSquadOfType(SquadType type)
{
return Squads.Find(s => s.Type == type);
return Squads.FirstOrDefault(s => s.Type == type);
}
Squad RegisterNewSquad(IBot bot, SquadType type, (Actor Actor, WVec Offset) target = default)