slight performance improvement over previous commit
@@ -97,6 +97,7 @@ public class LeafMapping extends AbstractCodeMapping implements Comparable<LeafM
Set<ReplacementType> otherReplacementTypes = o.getReplacementTypes();
Set<ReplacementType> intersection = new LinkedHashSet<>(thisReplacementTypes);
intersection.retainAll(otherReplacementTypes);
+ if(intersection.size() > 0 && (intersection.equals(thisReplacementTypes) || intersection.equals(otherReplacementTypes))) {
Set<ReplacementType> thisReplacementTypesWithoutCommon = new LinkedHashSet<>(thisReplacementTypes);
thisReplacementTypesWithoutCommon.removeAll(intersection);
Set<ReplacementType> otherReplacementTypesWithoutCommon = new LinkedHashSet<>(otherReplacementTypes);
@@ -144,7 +145,7 @@ public class LeafMapping extends AbstractCodeMapping implements Comparable<LeafM
else if(otherReplacementTypesWithoutCommon.size() > 0) {
identicalNodes = identicalNodesCount == otherReplacementTypesWithoutCommon.size();
}
- if(intersection.size() > 0 && sameReplacementCount == intersection.size() && identicalNodes) {
+ if(sameReplacementCount == intersection.size() && identicalNodes) {
if(intersection.equals(thisReplacementTypes) && !intersection.equals(otherReplacementTypes)) {
return -1;
}
@@ -152,6 +153,7 @@ public class LeafMapping extends AbstractCodeMapping implements Comparable<LeafM
return 1;
}
}
+ }
return Double.compare(distance1, distance2);
}
else {
