You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Mike Bowler <mb...@GargoyleSoftware.com> on 2003/01/21 16:38:07 UTC
[PATCH][LANG] Initial collection sizes in Enum.java
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