summaryrefslogtreecommitdiffstats
path: root/bcel-builder
diff options
context:
space:
mode:
authoraclement <aclement>2008-06-23 04:01:11 +0000
committeraclement <aclement>2008-06-23 04:01:11 +0000
commit00da5fd6edd87dbcb273eca3050991e22dec324d (patch)
treeaab5c45ec138b73b26f7630898c170f2ba59cf01 /bcel-builder
parentee857bb354fb193af9319b4bd9defbbb174d7522 (diff)
downloadaspectj-00da5fd6edd87dbcb273eca3050991e22dec324d.tar.gz
aspectj-00da5fd6edd87dbcb273eca3050991e22dec324d.zip
PERFORMANCE: cache field lookups
Diffstat (limited to 'bcel-builder')
-rw-r--r--bcel-builder/src/org/aspectj/apache/bcel/classfile/ConstantPool.java17
1 files changed, 12 insertions, 5 deletions
diff --git a/bcel-builder/src/org/aspectj/apache/bcel/classfile/ConstantPool.java b/bcel-builder/src/org/aspectj/apache/bcel/classfile/ConstantPool.java
index 31157a48d..d9e36ca18 100644
--- a/bcel-builder/src/org/aspectj/apache/bcel/classfile/ConstantPool.java
+++ b/bcel-builder/src/org/aspectj/apache/bcel/classfile/ConstantPool.java
@@ -1,13 +1,15 @@
package org.aspectj.apache.bcel.classfile;
-import org.aspectj.apache.bcel.Constants;
-import org.aspectj.apache.bcel.generic.*;
-
-import java.io.*;
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
import java.util.HashMap;
-import java.util.List;
import java.util.Map;
+import org.aspectj.apache.bcel.Constants;
+import org.aspectj.apache.bcel.generic.ArrayType;
+import org.aspectj.apache.bcel.generic.ObjectType;
+
/**
* This class represents the constant pool, i.e., a table of constants, of
* a parsed classfile. It may contain null references, due to the JVM
@@ -20,6 +22,7 @@ public class ConstantPool implements Node {
private Map utf8Cache = new HashMap();
private Map methodCache = new HashMap();
+ private Map fieldCache = new HashMap();
public int getSize() { return poolSize; }
@@ -324,6 +327,9 @@ public class ConstantPool implements Node {
public int lookupFieldref(String searchClassname, String searchFieldname, String searchSignature) {
searchClassname = searchClassname.replace('.','/');
+ String k = new StringBuffer().append(searchClassname).append(searchFieldname).append(searchSignature).toString();
+ Integer pos = (Integer) fieldCache.get(k);
+ if (pos!=null) return pos.intValue();
for (int i=1;i<poolSize;i++) {
Constant c = pool[i];
if (c!=null && c.tag==Constants.CONSTANT_Fieldref) {
@@ -341,6 +347,7 @@ public class ConstantPool implements Node {
if (!name.equals(searchFieldname)) continue; // not this one
String typeSignature = ((ConstantUtf8)pool[cnat.getSignatureIndex()]).getBytes();
if (!typeSignature.equals(searchSignature)) continue;
+ fieldCache.put(k,new Integer(i));
return i;
}
}