RFR JDK-8011200 (was 7143928) : (coll) Optimize for Empty ArrayList and HashMap

Alan Bateman Alan.Bateman at oracle.com
Mon Apr 8 12:52:46 UTC 2013


On 06/04/2013 23:02, Mike Duigou wrote:
> Hello all;
>
> Another, and hopefully the final, update to the webrev for this issue. The revised webrev is here:
>
> http://cr.openjdk.java.net/~mduigou/JDK-8011200/1/webrev/
>
> The important changes in this revision:
>
> - I've removed the serialData change in HashMap. The implementation now reads the capacity and gracefully handles non-power of 2 values.
>
> - I'm not entirely convinced that having serialization emulate clone() for capacity handling is the best answer. I might also want to change clone() to size it's result based upon the number of mappings in the source rather its the capacity. Anybody have strong feelings about this to suggest one behaviour is obviously better?
>
> Any other final thoughts?
>
> Mike
>
I think this is the webrev:

http://cr.openjdk.java.net/~mduigou/JDK-8011200/2/webrev/

It's impossible to predict what the usage will be after you 
reconstitute. Personally I think it's better to leave it as is, meaning 
the rounded-up size as otherwise you might reconstitute to a capacity 
that is much more than you might ever need.

I didn't notice in the previous revisions but roundUpToPowerOf2 can 
assign "rounded" twice (it probably doesn't happen when it gets compiled 
at runtime but still looks a bit odd).

The test still have the bug issue number.

-Alan




More information about the core-libs-dev mailing list