The short summary is:
- One HashMap is intended to always be empty but it was created with the default constructor which gives it an initial size of 101. Changed this to an initial size of 1 which will use less memory.
- The default constructor on HashMap uses a size of 101 which doesn't scale very well. If the collection has to grow to a larger size then this starting size quickly becomes non-prime which will degrade performance. A starting size of 89 is better as it remains prime for longer. Changed a couple of places that were using the default constructor to use a size of 89.
- One HashMap was created with an initial size of 50. For best performance, you always want the size of the collection to be a prime number. Even numbers will give particularly bad performance. Changed this to 89.
--
Mike Bowler
Principal, Gargoyle Software Inc.
Voice: (416) 822-0973 | Email : [EMAIL PROTECTED]
Fax : (416) 822-0975 | Website: http://www.GargoyleSoftware.com
Index: lang/src/java/org/apache/commons/lang/enum/Enum.java
===================================================================
RCS file:
/home/cvspublic/jakarta-commons/lang/src/java/org/apache/commons/lang/enum/Enum.java,v
retrieving revision 1.6
diff -u -r1.6 Enum.java
--- lang/src/java/org/apache/commons/lang/enum/Enum.java 31 Dec 2002 22:39:39
-0000 1.6
+++ lang/src/java/org/apache/commons/lang/enum/Enum.java 21 Jan 2003 15:18:53
+-0000
@@ -162,11 +162,11 @@
/**
* An empty map, as JDK1.2 didn't have an empty map
*/
- private static final Map EMPTY_MAP = Collections.unmodifiableMap(new HashMap());
+ private static final Map EMPTY_MAP = Collections.unmodifiableMap(new HashMap(1));
/**
* Map, key of class name, value of Entry.
*/
- private static final Map cEnumClasses = new HashMap();
+ private static final Map cEnumClasses = new HashMap(89);
/**
* The string representation of the Enum.
*/
@@ -177,7 +177,7 @@
*/
private static class Entry {
/** Map of Enum name to Enum */
- final Map map = new HashMap(50);
+ final Map map = new HashMap(89);
/** List of Enums in source code order */
final List list = new ArrayList(25);
@@ -197,7 +197,7 @@
protected Enum(String name) {
super();
if (name == null || name.length() == 0) {
- throw new IllegalArgumentException("The Enum name must not be empty");
+ throw new IllegalArgumentException("The Enum name must not be empty or
+null");
}
iName = name;
String className = Enum.getEnumClassName(getClass());-- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
