RFR 8005698 : Handle Frequent HashMap Collisions with Balanced Trees

Paul Sandoz paul.sandoz at oracle.com
Mon Jun 3 07:56:42 UTC 2013


Hi Brent,

On Jun 3, 2013, at 7:56 AM, Brent Christian <brent.christian at oracle.com> wrote:
> I went ahead and created a new webrev.  It includes this change, and the comment changes suggested by Alan:
> 
> http://cr.openjdk.java.net/~bchristi/8005698/webrev.04/
> 

A minor thing: take it or leave it :-)

In HashMap:

2207     void addEntry(int hash, K key, V value, int bucketIndex, boolean checkIfNeedTree) {
2208         // assert key != null;
2209         if ((size >= threshold) && (null != table[bucketIndex])) {
2210             resize(2 * table.length);
2211             hash = hash(key);
2212             bucketIndex = indexFor(hash, table.length);
2213         }
2214         createEntry(hash, key, value, bucketIndex, checkIfNeedTree);
2215     }

You could re-verify the bucket size if the table is resized rather than in createEntry, since that AFAICT is the only case where conditions after the call to addEntry might change.

Pau.




More information about the core-libs-dev mailing list