Index: main/java/org/apache/harmony/pack200/SegmentConstantPool.java =================================================================== --- main/java/org/apache/harmony/pack200/SegmentConstantPool.java (revision 643969) +++ main/java/org/apache/harmony/pack200/SegmentConstantPool.java (working copy) @@ -290,47 +290,4 @@ throw new Error("Get value incomplete"); } } - - protected ConstantPoolEntry cachedCpAll[] = {}; - public ConstantPoolEntry[] getCpAll() throws Pack200Exception { - if(cachedCpAll.length == 0) { - ArrayList cpAll = new ArrayList(); - // TODO: this is 1.5-specific. Try to get rid - // of it. - for(int index=0; index < bands.getCpUTF8().length; index++) { - cpAll.add(getConstantPoolEntry(UTF_8, index)); - } - for(int index=0; index < bands.getCpInt().length; index++) { - cpAll.add(getConstantPoolEntry(CP_INT, index)); - } - for(int index=0; index < bands.getCpFloat().length; index++) { - cpAll.add(getConstantPoolEntry(CP_FLOAT, index)); - } - for(int index=0; index < bands.getCpLong().length; index++) { - cpAll.add(getConstantPoolEntry(CP_LONG, index)); - } - for(int index=0; index < bands.getCpDouble().length; index++) { - cpAll.add(getConstantPoolEntry(CP_DOUBLE, index)); - } - for(int index=0; index < bands.getCpString().length; index++) { - cpAll.add(getConstantPoolEntry(CP_STRING, index)); - } - for(int index=0; index < bands.getCpClass().length; index++) { - cpAll.add(getConstantPoolEntry(CP_CLASS, index)); - } - for(int index=0; index < bands.getCpFieldClass().length; index++) { - cpAll.add(getConstantPoolEntry(CP_FIELD, index)); - } - for(int index=0; index < bands.getCpMethodClass().length; index++) { - cpAll.add(getConstantPoolEntry(CP_METHOD, index)); - } - for(int index=0; index < bands.getCpIMethodClass().length; index++) { - cpAll.add(getConstantPoolEntry(CP_IMETHOD, index)); - } - ConstantPoolEntry[] result = new ConstantPoolEntry[cpAll.size()]; - cpAll.toArray(result); - cachedCpAll = result; - } - return cachedCpAll; - } } \ No newline at end of file Index: main/java/org/apache/harmony/pack200/bytecode/CPUTF8.java =================================================================== --- main/java/org/apache/harmony/pack200/bytecode/CPUTF8.java (revision 643969) +++ main/java/org/apache/harmony/pack200/bytecode/CPUTF8.java (working copy) @@ -50,10 +50,12 @@ } public int hashCode() { + // Warning: this method has been optimized because + // it's called a lot. If utf8 + // is not set, the method will fail with a + // NullPointerException. final int PRIME = 31; - int result = 1; - result = PRIME * result + ((utf8 == null) ? 0 : utf8.hashCode()); - return result; + return PRIME + utf8.hashCode(); } public String toString() { Index: main/java/org/apache/harmony/pack200/bytecode/CPClass.java =================================================================== --- main/java/org/apache/harmony/pack200/bytecode/CPClass.java (revision 643969) +++ main/java/org/apache/harmony/pack200/bytecode/CPClass.java (working copy) @@ -61,11 +61,12 @@ public int hashCode() { - final int PRIME = 31; - int result = 1; - result = PRIME * result + ((name == null) ? 0 : name.hashCode()); - result = PRIME * result + ((utf8 == null) ? 0 : utf8.hashCode()); - return result; + // Warning: this method has been optimized because + // it's called a lot. If name or utf8 + // is not set, the method will fail with a + // NullPointerException. + final int PRIME = 19; + return (PRIME * name.hashCode()) + utf8.hashCode(); } protected void resolve(ClassConstantPool pool) { Index: main/java/org/apache/harmony/pack200/bytecode/CPRef.java =================================================================== --- main/java/org/apache/harmony/pack200/bytecode/CPRef.java (revision 643969) +++ main/java/org/apache/harmony/pack200/bytecode/CPRef.java (working copy) @@ -65,13 +65,12 @@ } public int hashCode() { - final int PRIME = 31; - int result = 1; - result = PRIME * result - + ((className == null) ? 0 : className.hashCode()); - result = PRIME * result - + ((nameAndType == null) ? 0 : nameAndType.hashCode()); - return result; + // Warning: this method has been optimized because + // it's called a lot. If className or nameAndType + // is not set, the method will fail with a + // NullPointerException. + final int PRIME = 37; + return (PRIME * className.hashCode()) + nameAndType.hashCode(); } protected void resolve(ClassConstantPool pool) {