Make MappingDataNode.Equals take 2952 times less time to run when loading maps (#5781)

This commit is contained in:
DrSmugleaf
2025-03-26 18:52:29 -07:00
committed by DrSmugleaf
parent 3ae65f9e3d
commit 6ff060c7f6

View File

@@ -384,9 +384,16 @@ namespace Robust.Shared.Serialization.Markdown.Mapping
if (_children.Count != other._children.Count)
return false;
// Given that keys are unique and we do not care about the ordering, we know that if removing identical
// key-value pairs leaves us with an empty list then the mappings are equal.
return Except(other) == null && Tag == other.Tag;
foreach (var (key, otherValue) in other)
{
if (!_children.TryGetValue(key, out var ownValue) ||
!otherValue.Equals(ownValue))
{
return false;
}
}
return Tag == other.Tag;
}
public override MappingDataNode PushInheritance(MappingDataNode node)