Use more efficient search in MergeIntoResolved

Switch Enumerable.FirstOrDefault to List.Find. The latter can avoid some allocations because the concrete collection type is known.
This commit is contained in:
RoosterDragon
2022-01-29 20:21:56 +00:00
committed by reaperrr
parent ed72e61f8f
commit f5d1fe4bc4

View File

@@ -338,7 +338,7 @@ namespace OpenRA
static void MergeIntoResolved(MiniYamlNode overrideNode, List<MiniYamlNode> existingNodes, static void MergeIntoResolved(MiniYamlNode overrideNode, List<MiniYamlNode> existingNodes,
Dictionary<string, MiniYaml> tree, Dictionary<string, MiniYamlNode.SourceLocation> inherited) Dictionary<string, MiniYaml> tree, Dictionary<string, MiniYamlNode.SourceLocation> inherited)
{ {
var existingNode = existingNodes.FirstOrDefault(n => n.Key == overrideNode.Key); var existingNode = existingNodes.Find(n => n.Key == overrideNode.Key);
if (existingNode != null) if (existingNode != null)
{ {
existingNode.Value = MergePartial(existingNode.Value, overrideNode.Value); existingNode.Value = MergePartial(existingNode.Value, overrideNode.Value);