From: aclement Date: Thu, 19 Jun 2008 18:10:40 +0000 (+0000) Subject: 231396: caching X-Git-Tag: V1_6_1rc1~28 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=c3400e82f6606bdc75bf0465475cb07a9643e5b2;p=aspectj.git 231396: caching --- 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 7c31b213d..31157a48d 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/classfile/ConstantPool.java +++ b/bcel-builder/src/org/aspectj/apache/bcel/classfile/ConstantPool.java @@ -4,6 +4,9 @@ import org.aspectj.apache.bcel.Constants; import org.aspectj.apache.bcel.generic.*; import java.io.*; +import java.util.HashMap; +import java.util.List; +import java.util.Map; /** * This class represents the constant pool, i.e., a table of constants, of @@ -15,6 +18,9 @@ public class ConstantPool implements Node { private Constant[] pool; private int poolSize; // number of entries in the pool (could be < pool.length as the array is resized in 'chunks') + private Map utf8Cache = new HashMap(); + private Map methodCache = new HashMap(); + public int getSize() { return poolSize; } public ConstantPool() { @@ -228,10 +234,15 @@ public class ConstantPool implements Node { public int lookupUtf8(String string) { + Integer pos = (Integer) utf8Cache.get(string); + if (pos!=null) return pos.intValue(); for (int i=1;i