[jboss-cvs] javassist SVN: r538 - trunk/src/main/javassist/bytecode.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Apr 28 06:26:29 EDT 2010


Author: chiba
Date: 2010-04-28 06:26:27 -0400 (Wed, 28 Apr 2010)
New Revision: 538

Modified:
   trunk/src/main/javassist/bytecode/AttributeInfo.java
   trunk/src/main/javassist/bytecode/FieldInfo.java
   trunk/src/main/javassist/bytecode/LongVector.java
   trunk/src/main/javassist/bytecode/MethodInfo.java
Log:
for performance tuning

Modified: trunk/src/main/javassist/bytecode/AttributeInfo.java
===================================================================
--- trunk/src/main/javassist/bytecode/AttributeInfo.java	2010-04-21 15:28:16 UTC (rev 537)
+++ trunk/src/main/javassist/bytecode/AttributeInfo.java	2010-04-28 10:26:27 UTC (rev 538)
@@ -19,7 +19,7 @@
 import java.io.DataOutputStream;
 import java.io.IOException;
 import java.util.Map;
-import java.util.LinkedList;
+import java.util.ArrayList;
 import java.util.ListIterator;
 import java.util.List;
 import java.util.Iterator;
@@ -185,7 +185,7 @@
             out.write(info);
     }
 
-    static int getLength(LinkedList list) {
+    static int getLength(ArrayList list) {
         int size = 0;
         int n = list.size();
         for (int i = 0; i < n; ++i) {
@@ -196,7 +196,7 @@
         return size;
     }
 
-    static AttributeInfo lookup(LinkedList list, String name) {
+    static AttributeInfo lookup(ArrayList list, String name) {
         if (list == null)
             return null;
 
@@ -210,7 +210,7 @@
         return null;            // no such attribute
     }
 
-    static synchronized void remove(LinkedList list, String name) {
+    static synchronized void remove(ArrayList list, String name) {
         if (list == null)
             return;
 
@@ -222,7 +222,7 @@
         }
     }
 
-    static void writeAll(LinkedList list, DataOutputStream out)
+    static void writeAll(ArrayList list, DataOutputStream out)
         throws IOException
     {
         if (list == null)
@@ -235,11 +235,11 @@
         }
     }
 
-    static LinkedList copyAll(LinkedList list, ConstPool cp) {
+    static ArrayList copyAll(ArrayList list, ConstPool cp) {
         if (list == null)
             return null;
 
-        LinkedList newList = new LinkedList();
+        ArrayList newList = new ArrayList();
         int n = list.size();
         for (int i = 0; i < n; ++i) {
             AttributeInfo attr = (AttributeInfo)list.get(i);

Modified: trunk/src/main/javassist/bytecode/FieldInfo.java
===================================================================
--- trunk/src/main/javassist/bytecode/FieldInfo.java	2010-04-21 15:28:16 UTC (rev 537)
+++ trunk/src/main/javassist/bytecode/FieldInfo.java	2010-04-28 10:26:27 UTC (rev 538)
@@ -19,7 +19,7 @@
 import java.io.DataOutputStream;
 import java.io.IOException;
 import java.util.List;
-import java.util.LinkedList;
+import java.util.ArrayList;
 
 /**
  * <code>field_info</code> structure.
@@ -33,7 +33,7 @@
     String cachedName;
     String cachedType;
     int descriptor;
-    LinkedList attribute;       // may be null.
+    ArrayList attribute;       // may be null.
 
     private FieldInfo(ConstPool cp) {
         constPool = cp;
@@ -85,7 +85,7 @@
     }
 
     void prune(ConstPool cp) {
-        LinkedList newAttributes = new LinkedList();
+        ArrayList newAttributes = new ArrayList();
         AttributeInfo invisibleAnnotations
             = getAttribute(AnnotationsAttribute.invisibleTag);
         if (invisibleAnnotations != null) {
@@ -212,7 +212,7 @@
      */
     public List getAttributes() {
         if (attribute == null)
-            attribute = new LinkedList();
+            attribute = new ArrayList();
 
         return attribute;
     }
@@ -236,7 +236,7 @@
      */
     public void addAttribute(AttributeInfo info) {
         if (attribute == null)
-            attribute = new LinkedList();
+            attribute = new ArrayList();
 
         AttributeInfo.remove(attribute, info.getName());
         attribute.add(info);
@@ -247,7 +247,7 @@
         name = in.readUnsignedShort();
         descriptor = in.readUnsignedShort();
         int n = in.readUnsignedShort();
-        attribute = new LinkedList();
+        attribute = new ArrayList();
         for (int i = 0; i < n; ++i)
             attribute.add(AttributeInfo.read(constPool, in));
     }

Modified: trunk/src/main/javassist/bytecode/LongVector.java
===================================================================
--- trunk/src/main/javassist/bytecode/LongVector.java	2010-04-21 15:28:16 UTC (rev 537)
+++ trunk/src/main/javassist/bytecode/LongVector.java	2010-04-28 10:26:27 UTC (rev 538)
@@ -19,17 +19,17 @@
     static final int ASIZE = 128;
     static final int ABITS = 7;  // ASIZE = 2^ABITS
     static final int VSIZE = 8;
-    private Object[][] objects;
+    private ConstInfo[][] objects;
     private int elements;
 
     public LongVector() {
-        objects = new Object[VSIZE][];
+        objects = new ConstInfo[VSIZE][];
         elements = 0;
     }
 
     public LongVector(int initialSize) {
         int vsize = ((initialSize >> ABITS) & ~(VSIZE - 1)) + VSIZE;
-        objects = new Object[vsize][];
+        objects = new ConstInfo[vsize][];
         elements = 0;
     }
 
@@ -37,25 +37,25 @@
 
     public int capacity() { return objects.length * ASIZE; }
 
-    public Object elementAt(int i) {
+    public ConstInfo elementAt(int i) {
         if (i < 0 || elements <= i)
             return null;
 
         return objects[i >> ABITS][i & (ASIZE - 1)];
     }
 
-    public void addElement(Object value) {
+    public void addElement(ConstInfo value) {
         int nth = elements >> ABITS;
         int offset = elements & (ASIZE - 1);
         int len = objects.length;
         if (nth >= len) { 
-            Object[][] newObj = new Object[len + VSIZE][];
+            ConstInfo[][] newObj = new ConstInfo[len + VSIZE][];
             System.arraycopy(objects, 0, newObj, 0, len);
             objects = newObj;
         }
 
         if (objects[nth] == null)
-            objects[nth] = new Object[ASIZE];
+            objects[nth] = new ConstInfo[ASIZE];
 
         objects[nth][offset] = value;
         elements++;

Modified: trunk/src/main/javassist/bytecode/MethodInfo.java
===================================================================
--- trunk/src/main/javassist/bytecode/MethodInfo.java	2010-04-21 15:28:16 UTC (rev 537)
+++ trunk/src/main/javassist/bytecode/MethodInfo.java	2010-04-28 10:26:27 UTC (rev 538)
@@ -18,7 +18,7 @@
 import java.io.DataInputStream;
 import java.io.DataOutputStream;
 import java.io.IOException;
-import java.util.LinkedList;
+import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
 import javassist.ClassPool;
@@ -30,13 +30,13 @@
  * @see javassist.CtMethod#getMethodInfo()
  * @see javassist.CtConstructor#getMethodInfo()
  */
-public final class MethodInfo {
+public class MethodInfo {
     ConstPool constPool;
     int accessFlags;
     int name;
     String cachedName;
     int descriptor;
-    LinkedList attribute; // may be null
+    ArrayList attribute; // may be null
 
     /**
      * If this value is true, Javassist maintains a <code>StackMap</code> attribute
@@ -134,7 +134,7 @@
     }
 
     void prune(ConstPool cp) {
-        LinkedList newAttributes = new LinkedList();
+        ArrayList newAttributes = new ArrayList();
 
         AttributeInfo invisibleAnnotations
             = getAttribute(AnnotationsAttribute.invisibleTag);
@@ -283,7 +283,7 @@
      */
     public List getAttributes() {
         if (attribute == null)
-            attribute = new LinkedList();
+            attribute = new ArrayList();
 
         return attribute;
     }
@@ -308,7 +308,7 @@
      */
     public void addAttribute(AttributeInfo info) {
         if (attribute == null)
-            attribute = new LinkedList();
+            attribute = new ArrayList();
 
         AttributeInfo.remove(attribute, info.getName());
         attribute.add(info);
@@ -352,7 +352,7 @@
     public void setExceptionsAttribute(ExceptionsAttribute cattr) {
         removeExceptionsAttribute();
         if (attribute == null)
-            attribute = new LinkedList();
+            attribute = new ArrayList();
 
         attribute.add(cattr);
     }
@@ -374,7 +374,7 @@
     public void setCodeAttribute(CodeAttribute cattr) {
         removeCodeAttribute();
         if (attribute == null)
-            attribute = new LinkedList();
+            attribute = new ArrayList();
 
         attribute.add(cattr);
     }
@@ -507,7 +507,7 @@
         String desc2 = Descriptor.rename(desc, classnames);
         descriptor = destCp.addUtf8Info(desc2);
 
-        attribute = new LinkedList();
+        attribute = new ArrayList();
         ExceptionsAttribute eattr = src.getExceptionsAttribute();
         if (eattr != null)
             attribute.add(eattr.copy(destCp, classnames));
@@ -522,7 +522,7 @@
         name = in.readUnsignedShort();
         descriptor = in.readUnsignedShort();
         int n = in.readUnsignedShort();
-        attribute = new LinkedList();
+        attribute = new ArrayList();
         for (int i = 0; i < n; ++i)
             attribute.add(AttributeInfo.read(constPool, in));
     }




More information about the jboss-cvs-commits mailing list