Skip to content

Commit

Permalink
can avoid craetion of temporary list
Browse files Browse the repository at this point in the history
  • Loading branch information
bodewig committed Dec 16, 2021
1 parent 4553a26 commit 1d83bdd
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/main/net-core/Diff/DOMDifferenceEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -468,13 +468,11 @@ private ComparisonState CompareNodeLists(IEnumerable<XmlNode> allControlChildren

IEnumerable<KeyValuePair<XmlNode, XmlNode>> matches =
NodeMatcher.Match(controlSeq, testSeq);
IList<XmlNode> controlListForXpath = new List<XmlNode>(allControlChildren);
IList<XmlNode> testListForXpath = new List<XmlNode>(allTestChildren);
IList<XmlNode> controlList = new List<XmlNode>(controlSeq);
IList<XmlNode> testList = new List<XmlNode>(testSeq);

IDictionary<XmlNode, int> controlListForXpathIndex = Index(controlListForXpath);
IDictionary<XmlNode, int> testListForXpathIndex = Index(testListForXpath);
IDictionary<XmlNode, int> controlListForXpathIndex = Index(allControlChildren);
IDictionary<XmlNode, int> testListForXpathIndex = Index(allTestChildren);
IDictionary<XmlNode, int> controlListIndex = Index(controlList);
IDictionary<XmlNode, int> testListIndex = Index(testList);

Expand Down Expand Up @@ -743,7 +741,7 @@ private static XmlAttribute FindMatchingAttr(IList<XmlAttribute> attrs,
return null;
}

private static IDictionary<XmlNode, int> Index(IList<XmlNode> nodes) {
private static IDictionary<XmlNode, int> Index(IEnumerable<XmlNode> nodes) {
IDictionary<XmlNode, int> indices = new Dictionary<XmlNode, int>();
int idx = 0;
foreach (XmlNode n in nodes) {
Expand Down

0 comments on commit 1d83bdd

Please sign in to comment.