Index: src/main/java/org/apache/harmony/unpack200/IcBands.java =================================================================== --- src/main/java/org/apache/harmony/unpack200/IcBands.java (revision 678402) +++ src/main/java/org/apache/harmony/unpack200/IcBands.java (working copy) @@ -19,7 +19,9 @@ import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; +import java.util.HashSet; import java.util.List; +import java.util.Set; import org.apache.harmony.pack200.Codec; import org.apache.harmony.pack200.Pack200Exception; @@ -118,11 +120,13 @@ * @return array of IcTuple */ public IcTuple[] getRelevantIcTuples(String className, ClassConstantPool cp) { + Set relevantTuplesContains = new HashSet(); List relevantTuples = new ArrayList(); IcTuple[] allTuples = getIcTuples(); int allTuplesSize = allTuples.length; for (int index = 0; index < allTuplesSize; index++) { if (allTuples[index].shouldAddToRelevantForClassName(className)) { + relevantTuplesContains.add(allTuples[index]); relevantTuples.add(allTuples[index]); } } @@ -142,7 +146,7 @@ if (poolClassName.equals(allTuples[allTupleIndex] .thisClassString())) { // If the tuple isn't already in there, then add it - if (relevantTuples.indexOf(allTuples[allTupleIndex]) == -1) { + if (relevantTuplesContains.add(allTuples[allTupleIndex])) { relevantTuples.add(allTuples[allTupleIndex]); changed = true; } @@ -161,7 +165,7 @@ ArrayList tuplesToAdd = new ArrayList(); while (changedFixup) { changedFixup = false; - for (int index = 0; index < relevantTuples.size(); index++) { + for(int index = 0; index < relevantTuples.size(); index++) { IcTuple aRelevantTuple = (IcTuple) relevantTuples.get(index); for (int allTupleIndex = 0; allTupleIndex < allTuplesSize; allTupleIndex++) { if (aRelevantTuple.outerClassString().equals( @@ -175,7 +179,7 @@ if (tuplesToAdd.size() > 0) { for(int index = 0; index < tuplesToAdd.size(); index++) { IcTuple tuple = (IcTuple) tuplesToAdd.get(index); - if (!relevantTuples.contains(tuple)) { + if (relevantTuplesContains.add(tuple)) { changedFixup = true; relevantTuples.add(tuple); } @@ -189,7 +193,7 @@ IcTuple[] orderedRelevantTuples = new IcTuple[relevantTuples.size()]; int orderedRelevantIndex = 0; for (int index = 0; index < allTuplesSize; index++) { - if (relevantTuples.contains(allTuples[index])) { + if (relevantTuplesContains.contains(allTuples[index])) { orderedRelevantTuples[orderedRelevantIndex] = allTuples[index]; orderedRelevantIndex++; } Index: src/main/java/org/apache/harmony/unpack200/IcTuple.java =================================================================== --- src/main/java/org/apache/harmony/unpack200/IcTuple.java (revision 678402) +++ src/main/java/org/apache/harmony/unpack200/IcTuple.java (working copy) @@ -75,6 +75,7 @@ private String cachedSimpleClassName; private boolean initialized; private boolean anonymous; + private boolean outerIsAnonymous; private boolean member = true; private int cachedOuterClassIndex = -1; private int cachedSimpleClassNameIndex = -1; @@ -155,7 +156,12 @@ return anonymous; } + public boolean outerIsAnonymous() { + return outerIsAnonymous; + } + + private boolean computeOuterIsAnonymous() { String[] result = innerBreakAtDollar(cachedOuterClassString); if (result.length == 0) { throw new Error( @@ -250,6 +256,8 @@ member = true; } } + + outerIsAnonymous = computeOuterIsAnonymous(); } private boolean isAllDigits(String nameString) { @@ -303,10 +311,23 @@ return true; } - public int hashCode() { - return 17 + C.hashCode() + C2.hashCode() + N.hashCode(); + private boolean hashcodeComputed; + private int cachedHashCode; + + private void generateHashCode() { + hashcodeComputed = true; + cachedHashCode = 17; + if(C != null) { cachedHashCode =+ C.hashCode(); } + if(C2 != null) { cachedHashCode =+ C2.hashCode(); } + if(N != null) { cachedHashCode =+ N.hashCode(); } } + public int hashCode() { + if (!hashcodeComputed) + generateHashCode(); + return cachedHashCode; + } + public String getC() { return C; }