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:
@@ -102,7 +102,7 @@ namespace OpenRA.Mods.Common.UpdateRules.Rules
|
||||
refineryNode.RemoveNode(dockOffsetNode);
|
||||
}
|
||||
|
||||
var buildingNode = actorNode.Value.Nodes.Find(n => buildings.Any(b => n.KeyMatches(b, includeRemovals: false)));
|
||||
var buildingNode = actorNode.Value.Nodes.FirstOrDefault(n => buildings.Any(b => n.KeyMatches(b, includeRemovals: false)));
|
||||
if (buildingNode != null)
|
||||
{
|
||||
var dimensions = buildingNode.ChildrenMatching("Dimensions", includeRemovals: false).FirstOrDefault()?.NodeValue<CVec>() ?? new CVec(1, 1);
|
||||
|
||||
Reference in New Issue
Block a user