Hi, Paul

If a HashMap is created via serialization or clone(), we don't check if the table needs resizing when adding entries, but still need to check if a bin should be converted to a TreeBin. In this case, putForCreate() calls createEntry() directly, instead of addEntry().

Thanks,
-Brent

On 6/3/13 12:56 AM, Paul Sandoz wrote:
Hi Brent,

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.

Reply via email to