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:
@@ -9,7 +9,6 @@
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using OpenRA.Mods.Common.UpdateRules.Rules;
|
||||
@@ -99,7 +98,7 @@ namespace OpenRA.Mods.Common.UpdateRules
|
||||
if (namedType != null && namedType.IsSubclassOf(typeof(UpdateRule)))
|
||||
return new[] { (UpdateRule)objectCreator.CreateBasic(namedType) };
|
||||
|
||||
return Array.Find(Paths, p => p.source == source)?.Rules(chain);
|
||||
return Paths.FirstOrDefault(p => p.source == source)?.Rules(chain);
|
||||
}
|
||||
|
||||
public static IEnumerable<string> KnownPaths { get { return Paths.Select(p => p.source); } }
|
||||
|
||||
Reference in New Issue
Block a user