commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mike Bowler <mbow...@GargoyleSoftware.com>
Subject [PATCH][LANG] Initial collection sizes in Enum.java
Date Tue, 21 Jan 2003 15:38:07 GMT
The Enum class has some initial collection sizes that aren't terribly 
good for performance.  This patch provides better initial sizes and 
improves one exception message.

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  : mbowler@GargoyleSoftware.com
Fax  : (416) 822-0975 | Website: http://www.GargoyleSoftware.com

Mime
View raw message