Skip to content

Commit aa329de

Browse files
committed
actually there is no reason to keep a temporary list
see #236
1 parent 9b1ca58 commit aa329de

File tree

1 file changed

+8
-16
lines changed

1 file changed

+8
-16
lines changed

xmlunit-core/src/main/java/org/xmlunit/diff/DOMDifferenceEngine.java

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -581,13 +581,11 @@ private ComparisonState compareNodeLists(Iterable<Node> allControlChildren,
581581

582582
Iterable<Map.Entry<Node, Node>> matches =
583583
getNodeMatcher().match(controlSeq, testSeq);
584-
List<Node> controlListForXpath = Linqy.asList(allControlChildren);
585-
List<Node> testListForXpath = Linqy.asList(allTestChildren);
586584
List<Node> controlList = Linqy.asList(controlSeq);
587585
List<Node> testList = Linqy.asList(testSeq);
588586

589-
final Map<Node, Integer> controlListForXpathIndex = index(controlListForXpath);
590-
final Map<Node, Integer> testListForXpathIndex = index(testListForXpath);
587+
final Map<Node, Integer> controlListForXpathIndex = index(allControlChildren);
588+
final Map<Node, Integer> testListForXpathIndex = index(allTestChildren);
591589
final Map<Node, Integer> controlListIndex = index(controlList);
592590
final Map<Node, Integer> testListIndex = index(testList);
593591

@@ -628,26 +626,23 @@ public ComparisonState apply() {
628626
}
629627
}
630628

631-
return chain.andThen(new UnmatchedControlNodes(controlListForXpath, controlListForXpathIndex,
632-
controlList, controlContext, seen, testContext))
633-
.andThen(new UnmatchedTestNodes(testListForXpath, testListForXpathIndex, testList,
629+
return chain.andThen(new UnmatchedControlNodes(controlListForXpathIndex, controlList,
630+
controlContext, seen, testContext))
631+
.andThen(new UnmatchedTestNodes(testListForXpathIndex, testList,
634632
testContext, seen, controlContext));
635633
}
636634

637635
private class UnmatchedControlNodes implements DeferredComparison {
638-
private final List<Node> controlListForXpath;
639636
private final Map<Node, Integer> controlListForXpathIndex;
640637
private final List<Node> controlList;
641638
private final XPathContext controlContext;
642639
private final Set<Node> seen;
643640
private final XPathContext testContext;
644641

645-
private UnmatchedControlNodes(List<Node> controlListForXpath,
646-
Map<Node, Integer> controlListForXpathIndex,
642+
private UnmatchedControlNodes(Map<Node, Integer> controlListForXpathIndex,
647643
List<Node> controlList,
648644
XPathContext controlContext,
649645
Set<Node> seen, XPathContext testContext) {
650-
this.controlListForXpath = controlListForXpath;
651646
this.controlListForXpathIndex = controlListForXpathIndex;
652647
this.controlList = controlList;
653648
this.controlContext = controlContext;
@@ -679,18 +674,15 @@ public ComparisonState apply() {
679674
}
680675

681676
private class UnmatchedTestNodes implements DeferredComparison {
682-
private final List<Node> testListForXpath;
683677
private final Map<Node, Integer> testListForXpathIndex;
684678
private final List<Node> testList;
685679
private final XPathContext testContext;
686680
private final Set<Node> seen;
687681
private final XPathContext controlContext;
688682

689-
private UnmatchedTestNodes(List<Node> testListForXpath,
690-
Map<Node, Integer> testListForXpathIndex,
683+
private UnmatchedTestNodes(Map<Node, Integer> testListForXpathIndex,
691684
List<Node> testList, XPathContext testContext,
692685
Set<Node> seen, XPathContext controlContext) {
693-
this.testListForXpath = testListForXpath;
694686
this.testListForXpathIndex = testListForXpathIndex;
695687
this.testList = testList;
696688
this.testContext = testContext;
@@ -896,7 +888,7 @@ private static Attr findMatchingAttr(final List<Attr> attrs,
896888
return null;
897889
}
898890

899-
private static Map<Node, Integer> index(final List<Node> nodes) {
891+
private static Map<Node, Integer> index(final Iterable<Node> nodes) {
900892
Map<Node, Integer> indices = new HashMap<Node, Integer>();
901893
int idx = 0;
902894
for (Node n : nodes) {

0 commit comments

Comments
 (0)