From f0b18d27f01492af6874baa8415ad17511eb5d4b Mon Sep 17 00:00:00 2001 From: "Gary D. Gregory" Date: Thu, 30 Oct 2014 12:24:46 +0000 Subject: [PATCH] Statement unnecessarily nested within else clause. git-svn-id: https://svn.apache.org/repos/asf/commons/proper/collections/trunk@1635476 13f79535-47bb-0310-9956-ffa450edef68 --- .../commons/collections4/list/TreeList.java | 75 +++++++++---------- 1 file changed, 34 insertions(+), 41 deletions(-) diff --git a/src/main/java/org/apache/commons/collections4/list/TreeList.java b/src/main/java/org/apache/commons/collections4/list/TreeList.java index ff9c576d5..ecd424ef1 100644 --- a/src/main/java/org/apache/commons/collections4/list/TreeList.java +++ b/src/main/java/org/apache/commons/collections4/list/TreeList.java @@ -865,48 +865,41 @@ public class TreeList extends AbstractList { s = sAncestor.balance(); } return s; - } else { - // CASE 2: This tree is taller. This is symmetric to case 1. - // We merge otherTree into this tree by finding a subtree s of this - // tree that is of similar height to otherTree and replacing it - // with a new subtree whose root is otherTreeMin and whose - // children are otherTree and s. - - otherTree = otherTree.removeMin(); - - final ArrayStack> sAncestors = new ArrayStack>(); - AVLNode s = this; - int sAbsolutePosition = s.relativePosition; - int sParentAbsolutePosition = 0; - while (s != null && s.height > getHeight(otherTree)) { - sParentAbsolutePosition = sAbsolutePosition; - sAncestors.push(s); - s = s.right; - if (s != null) { - sAbsolutePosition += s.relativePosition; - } - } - - otherTreeMin.setRight(otherTree, null); - otherTreeMin.setLeft(s, maxNode); - if (otherTree != null) { - otherTree.min().setLeft(null, otherTreeMin); - otherTree.relativePosition++; - } - if (s != null) { - s.max().setRight(null, otherTreeMin); - s.relativePosition = sAbsolutePosition - currentSize; - } - otherTreeMin.relativePosition = currentSize - sParentAbsolutePosition; - - s = otherTreeMin; - while (!sAncestors.isEmpty()) { - final AVLNode sAncestor = sAncestors.pop(); - sAncestor.setRight(s, null); - s = sAncestor.balance(); - } - return s; } + otherTree = otherTree.removeMin(); + + final ArrayStack> sAncestors = new ArrayStack>(); + AVLNode s = this; + int sAbsolutePosition = s.relativePosition; + int sParentAbsolutePosition = 0; + while (s != null && s.height > getHeight(otherTree)) { + sParentAbsolutePosition = sAbsolutePosition; + sAncestors.push(s); + s = s.right; + if (s != null) { + sAbsolutePosition += s.relativePosition; + } + } + + otherTreeMin.setRight(otherTree, null); + otherTreeMin.setLeft(s, maxNode); + if (otherTree != null) { + otherTree.min().setLeft(null, otherTreeMin); + otherTree.relativePosition++; + } + if (s != null) { + s.max().setRight(null, otherTreeMin); + s.relativePosition = sAbsolutePosition - currentSize; + } + otherTreeMin.relativePosition = currentSize - sParentAbsolutePosition; + + s = otherTreeMin; + while (!sAncestors.isEmpty()) { + final AVLNode sAncestor = sAncestors.pop(); + sAncestor.setRight(s, null); + s = sAncestor.balance(); + } + return s; } // private void checkFaedelung() {