Author: markt Date: Fri Sep 12 08:30:39 2014 New Revision: 1624476 URL: http://svn.apache.org/r1624476 Log: Remove the cache. Generally, it makes performance worse not better. Testing with the jars that ship with Jira, performance was improved by around 10-15% by removing the cache. Based on a suggestion by hzhang9
Modified: tomcat/trunk/java/org/apache/tomcat/util/bcel/classfile/ConstantUtf8.java Modified: tomcat/trunk/java/org/apache/tomcat/util/bcel/classfile/ConstantUtf8.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/bcel/classfile/ConstantUtf8.java?rev=1624476&r1=1624475&r2=1624476&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/tomcat/util/bcel/classfile/ConstantUtf8.java (original) +++ tomcat/trunk/java/org/apache/tomcat/util/bcel/classfile/ConstantUtf8.java Fri Sep 12 08:30:39 2014 @@ -18,9 +18,6 @@ package org.apache.tomcat.util.bcel.clas import java.io.DataInputStream; import java.io.IOException; -import java.util.HashMap; -import java.util.LinkedHashMap; -import java.util.Map; import org.apache.tomcat.util.bcel.Constants; @@ -37,39 +34,9 @@ public final class ConstantUtf8 extends private static final long serialVersionUID = 8119001312020421976L; private final String bytes; - private static final int MAX_CACHE_ENTRIES = 20000; - private static final int INITIAL_CACHE_CAPACITY = (int)(MAX_CACHE_ENTRIES/0.75); - private static HashMap<String, ConstantUtf8> cache; - - private static synchronized ConstantUtf8 getCachedInstance(String s) { - if (s.length() > 200) { - return new ConstantUtf8(s); - } - if (cache == null) { - cache = new LinkedHashMap<String, ConstantUtf8>(INITIAL_CACHE_CAPACITY, 0.75f, true) { - private static final long serialVersionUID = 1L; - - @Override - protected boolean removeEldestEntry(Map.Entry<String, ConstantUtf8> eldest) { - return size() > MAX_CACHE_ENTRIES; - } - }; - } - ConstantUtf8 result = cache.get(s); - if (result != null) { - return result; - } - result = new ConstantUtf8(s); - cache.put(s, result); - return result; - } - - private static ConstantUtf8 getInstance(String s) { - return getCachedInstance(s); - } static ConstantUtf8 getInstance(DataInputStream file) throws IOException { - return getInstance(file.readUTF()); + return new ConstantUtf8(file.readUTF()); } --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org