This is the mail archive of the
java@gcc.gnu.org
mailing list for the Java project.
Re: IdentityHashMap & natStackTrace
- From: Tom Tromey <tromey at redhat dot com>
- To: Ranjit Mathew <rmathew at gmail dot com>
- Cc: Rutger Ovidius <r_ovidius at eml dot cc>, GCJ <java at gcc dot gnu dot org>
- Date: 26 Nov 2004 10:26:42 -0700
- Subject: Re: IdentityHashMap & natStackTrace
- References: <852788001.20041125111906@eml.cc> <41A6CC2B.3050803@gmail.com>
- Reply-to: tromey at redhat dot com
>>>>> "Ranjit" == Ranjit Mathew <rmathew@gmail.com> writes:
Ranjit> This was introduced almost two years ago in a merge from
Ranjit> Classpath:
Yeah, there was a wave of changing "* 2" to "<< 1". As Bryce and
Andrew point out, this is a non-optimization.
Ranjit> // This isn't necessarily prime, but it is an odd number of key/value
Ranjit> // slots, which has a higher probability of fewer collisions.
Ranjit> - table = new Object[old.length * 2 + 2];
Ranjit> + table = new Object[old.length << 1 + 2];
Ranjit> I think this is surely a bug - the comment above this line
Ranjit> didn't hold earlier and doesn't hold now - we still have
Ranjit> an even number of slots.
The comment is correct, just a little confusing. The missing piece of
information is that the table stores the key at index N and the value
at index N+1. So, adding 2 to the length of the underlying array
means that you're adding 1 to the size of the map, hence it is odd (as
the .length is always even).
Tom