harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sjanu...@apache.org
Subject svn commit: r689092 - in /harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200: CpBands.java bytecode/ClassConstantPool.java bytecode/forms/ByteCodeForm.java
Date Tue, 26 Aug 2008 14:23:30 GMT
Author: sjanuary
Date: Tue Aug 26 07:23:30 2008
New Revision: 689092

URL: http://svn.apache.org/viewvc?rev=689092&view=rev
Log:
Apply patch for HARMONY-5928 ([classlib][pack200][performance] java.util.HashMap usage optimization)

Modified:
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/CpBands.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/ClassConstantPool.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/forms/ByteCodeForm.java

Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/CpBands.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/CpBands.java?rev=689092&r1=689091&r2=689092&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/CpBands.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/CpBands.java
Tue Aug 26 07:23:30 2008
@@ -20,6 +20,7 @@
 import java.io.InputStream;
 import java.util.ArrayList;
 import java.util.HashMap;
+import java.util.Map;
 
 import org.apache.harmony.pack200.Codec;
 import org.apache.harmony.pack200.Pack200Exception;
@@ -73,19 +74,21 @@
     private int[] cpStringInts;
     private String[] cpUTF8;
 
-    private final HashMap stringsToCPUTF8 = new HashMap();
-    private final HashMap stringsToCPStrings = new HashMap();
-    private final HashMap longsToCPLongs = new HashMap();
-    private final HashMap integersToCPIntegers = new HashMap();
-    private final HashMap floatsToCPFloats = new HashMap();
-    private final HashMap stringsToCPClass = new HashMap();
-    private final HashMap doublesToCPDoubles = new HashMap();
-    private final HashMap descriptorsToCPNameAndTypes = new HashMap();
-
-    private HashMap mapClass = new HashMap();
-    private HashMap mapDescriptor = new HashMap();
-    private HashMap mapUTF8 = new HashMap();
-    private HashMap mapSignature = new HashMap();
+    private final Map stringsToCPUTF8 = new HashMap();
+    private final Map stringsToCPStrings = new HashMap();
+    private final Map longsToCPLongs = new HashMap();
+    private final Map integersToCPIntegers = new HashMap();
+    private final Map floatsToCPFloats = new HashMap();
+    private final Map stringsToCPClass = new HashMap();
+    private final Map doublesToCPDoubles = new HashMap();
+    private final Map descriptorsToCPNameAndTypes = new HashMap();
+
+    private Map mapClass;
+    private Map mapDescriptor;
+    private Map mapUTF8;
+    
+// TODO: Not used 
+//    private Map mapSignature;
 
     private int intOffset;
     private int floatOffset;
@@ -151,6 +154,7 @@
         int cpClassCount = header.getCpClassCount();
         cpClassInts = decodeBandInt("cp_Class", in, Codec.UDELTA5, cpClassCount);
         cpClass = new String[cpClassCount];
+        mapClass = new HashMap(cpClassCount);
         for (int i = 0; i < cpClassCount; i++) {
             cpClass[i] = cpUTF8[cpClassInts[i]];
             mapClass.put(cpClass[i], new Integer(i));
@@ -184,6 +188,7 @@
         String[] cpDescriptorTypes = getReferences(cpDescriptorTypeInts,
                 cpSignature);
         cpDescriptor = new String[cpDescriptorCount];
+        mapDescriptor = new HashMap(cpDescriptorCount);
         for (int i = 0; i < cpDescriptorCount; i++) {
             cpDescriptor[i] = cpDescriptorNames[i] + ":" + cpDescriptorTypes[i]; //$NON-NLS-1$
             mapDescriptor.put(cpDescriptor[i], new Integer(i));
@@ -401,6 +406,7 @@
             Pack200Exception {
         int cpUTF8Count = header.getCpUTF8Count();
         cpUTF8 = new String[cpUTF8Count];
+        mapUTF8 = new HashMap(cpUTF8Count+1);
         cpUTF8[0] = ""; //$NON-NLS-1$
         mapUTF8.put("", new Integer(0));
         int[] prefix = decodeBandInt("cpUTF8Prefix", in, Codec.DELTA5,
@@ -547,9 +553,10 @@
             if(index != null) {
             	return cpUTF8Value(index.intValue());
             }
-            if(searchForIndex) {
-            	index = (Integer)mapSignature.get(string);
-            }
+// TODO: mapSignature is not filled anywhere
+//            if(searchForIndex) {
+//            	index = (Integer)mapSignature.get(string);
+//            }
             if(index != null) {
             	return cpSignatureValue(index.intValue());
             }

Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/ClassConstantPool.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/ClassConstantPool.java?rev=689092&r1=689091&r2=689092&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/ClassConstantPool.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/ClassConstantPool.java
Tue Aug 26 07:23:30 2008
@@ -243,7 +243,7 @@
 
         // copy over and rebuild the cache
         //
-        indexCache = new HashMap();
+        indexCache = new HashMap(entries.size());
         int index = 0;
 
         entries.clear();

Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/forms/ByteCodeForm.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/forms/ByteCodeForm.java?rev=689092&r1=689091&r2=689092&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/forms/ByteCodeForm.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/bytecode/forms/ByteCodeForm.java
Tue Aug 26 07:23:30 2008
@@ -59,9 +59,9 @@
 
     protected static final boolean WIDENED = true;
 
-    protected static final Map byteCodes = new HashMap();
+    protected static final ByteCodeForm[] byteCodeArray = new ByteCodeForm[256];
+    protected static final Map byteCodesByName = new HashMap(256);
     static {
-        final ByteCodeForm[] byteCodeArray = new ByteCodeForm[256];
         byteCodeArray[0] = new NoArgumentForm(0, "nop");
         byteCodeArray[1] = new NoArgumentForm(1, "aconst_null");
         byteCodeArray[2] = new NoArgumentForm(2, "iconst_m1");
@@ -391,8 +391,7 @@
         for (int i = 0; i < byteCodeArray.length; i++) {
             final ByteCodeForm byteCode = byteCodeArray[i];
             if (byteCode != null) {
-                byteCodes.put(new Integer(i), byteCode);
-                byteCodes.put(byteCode.getName(), byteCode);
+                byteCodesByName.put(byteCode.getName(), byteCode);
             }
         }
     }
@@ -478,11 +477,11 @@
     }
 
     public static ByteCodeForm get(int opcode) {
-        return (ByteCodeForm) byteCodes.get(new Integer(opcode));
+        return (ByteCodeForm) byteCodeArray[opcode];
     }
 
     public static ByteCodeForm get(String name) {
-        return (ByteCodeForm) byteCodes.get(name);
+        return (ByteCodeForm) byteCodesByName.get(name);
     }
 
     public String toString() {



Mime
View raw message