From: aclement Date: Mon, 23 Jun 2008 04:01:11 +0000 (+0000) Subject: PERFORMANCE: cache field lookups X-Git-Tag: V1_6_1rc1~7 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=00da5fd6edd87dbcb273eca3050991e22dec324d;p=aspectj.git PERFORMANCE: cache field lookups --- 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