Use TryGetValue instead of ContainsKey followed by indexing
This commit is contained in:
@@ -203,10 +203,11 @@ namespace OpenRA.Mods.Common.Lint
|
|||||||
var nodeType = node.Key.Split('@')[0];
|
var nodeType = node.Key.Split('@')[0];
|
||||||
foreach (var childNode in node.Value.Nodes)
|
foreach (var childNode in node.Value.Nodes)
|
||||||
{
|
{
|
||||||
if (translatables.ContainsKey(nodeType))
|
if (!translatables.TryGetValue(nodeType, out var translationNodes))
|
||||||
{
|
continue;
|
||||||
|
|
||||||
var childType = childNode.Key.Split('@')[0];
|
var childType = childNode.Key.Split('@')[0];
|
||||||
var field = Array.Find(translatables[nodeType], t => t.Name == childType);
|
var field = Array.Find(translationNodes, t => t.Name == childType);
|
||||||
if (field.Name == null)
|
if (field.Name == null)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@@ -230,7 +231,6 @@ namespace OpenRA.Mods.Common.Lint
|
|||||||
|
|
||||||
referencedKeys.Add(key);
|
referencedKeys.Add(key);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var childNode in node.Value.Nodes)
|
foreach (var childNode in node.Value.Nodes)
|
||||||
if (childNode.Key == "Children")
|
if (childNode.Key == "Children")
|
||||||
|
|||||||
Reference in New Issue
Block a user