aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/javassist/bytecode
diff options
context:
space:
mode:
authorchiba <chiba@30ef5769-5b8d-40dd-aea6-55b5d6557bb3>2004-04-18 17:32:28 +0000
committerchiba <chiba@30ef5769-5b8d-40dd-aea6-55b5d6557bb3>2004-04-18 17:32:28 +0000
commit17ac0d828783b8f3036d259d618f5a8effd898d7 (patch)
treed8bdea70843a44d9322f97ecadaacb2389035625 /src/main/javassist/bytecode
parent4929508cfb11ea5ba2b3d0ff645e8f60c1e31519 (diff)
downloadjavassist-17ac0d828783b8f3036d259d618f5a8effd898d7.tar.gz
javassist-17ac0d828783b8f3036d259d618f5a8effd898d7.zip
edited for improving runtime performance.
git-svn-id: http://anonsvn.jboss.org/repos/javassist/trunk@88 30ef5769-5b8d-40dd-aea6-55b5d6557bb3
Diffstat (limited to 'src/main/javassist/bytecode')
-rw-r--r--src/main/javassist/bytecode/ConstPool.java34
-rw-r--r--src/main/javassist/bytecode/LongVector.java7
2 files changed, 25 insertions, 16 deletions
diff --git a/src/main/javassist/bytecode/ConstPool.java b/src/main/javassist/bytecode/ConstPool.java
index 8d850cac..d517b531 100644
--- a/src/main/javassist/bytecode/ConstPool.java
+++ b/src/main/javassist/bytecode/ConstPool.java
@@ -21,7 +21,7 @@ import java.io.ByteArrayOutputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.util.Map;
-import java.util.Hashtable;
+import java.util.HashMap;
import javassist.CtClass;
/**
@@ -30,10 +30,9 @@ import javassist.CtClass;
public final class ConstPool {
LongVector items;
int numOfItems;
- Hashtable classes;
- Hashtable strings;
+ HashMap classes;
+ HashMap strings;
int thisClassInfo;
- private static final int SIZE = 128;
/**
* <code>CONSTANT_Class</code>
@@ -103,7 +102,11 @@ public final class ConstPool {
* pool table
*/
public ConstPool(String thisclass) {
- this();
+ items = new LongVector();
+ numOfItems = 0;
+ addItem(null); // index 0 is reserved by the JVM.
+ classes = new HashMap();
+ strings = new HashMap();
thisClassInfo = addClassInfo(thisclass);
}
@@ -113,17 +116,12 @@ public final class ConstPool {
* @param in byte stream.
*/
public ConstPool(DataInputStream in) throws IOException {
- this();
- read(in);
- }
-
- private ConstPool() {
- items = new LongVector(SIZE);
- numOfItems = 0;
- addItem(null); // index 0 is reserved by the JVM.
- classes = new Hashtable();
- strings = new Hashtable();
+ classes = new HashMap();
+ strings = new HashMap();
thisClassInfo = 0;
+ /* read() initializes items and numOfItems, and do addItem(null).
+ */
+ read(in);
}
/**
@@ -861,6 +859,12 @@ public final class ConstPool {
private void read(DataInputStream in) throws IOException {
int n = in.readUnsignedShort();
+
+ int size = (n / LongVector.SIZE + 1) * LongVector.SIZE;
+ items = new LongVector(size);
+ numOfItems = 0;
+ addItem(null); // index 0 is reserved by the JVM.
+
while (--n > 0) { // index 0 is reserved by JVM
int tag = readOne(in);
if ((tag == LongInfo.tag) || (tag == DoubleInfo.tag)) {
diff --git a/src/main/javassist/bytecode/LongVector.java b/src/main/javassist/bytecode/LongVector.java
index c4be753e..279bb4fd 100644
--- a/src/main/javassist/bytecode/LongVector.java
+++ b/src/main/javassist/bytecode/LongVector.java
@@ -16,10 +16,15 @@
package javassist.bytecode;
final class LongVector {
+ static final int SIZE = 128;
private int num;
private Object[] objects;
private LongVector next;
+ public LongVector() {
+ this(SIZE);
+ }
+
public LongVector(int initialSize) {
num = 0;
objects = new Object[initialSize];
@@ -34,7 +39,7 @@ final class LongVector {
if (p.num < p.objects.length)
p.objects[p.num++] = obj;
else {
- LongVector q = p.next = new LongVector(p.objects.length);
+ LongVector q = p.next = new LongVector(SIZE);
q.objects[q.num++] = obj;
}
}