RFR(s): JDK-8214687 Optimize Collections.nCopies().hashCode()

Ivan Gerasimov ivan.gerasimov at oracle.com
Mon Dec 3 07:23:02 UTC 2018


Thank you Tagir!

I think your solution is quite clever, and the fix looks good.

While we are here:  Would it make sense to use CopiesList only for n > 
0, and make nCopies() and nCopies().subList() return 
Collection.emptyList() otherwise?

This would allow to remove the check for n == 0 in a couple of places.
Also an unnecessary reference to the `element` wouldn't be kept.

With kind regards,
Ivan


On 12/2/18 9:27 PM, Tagir Valeev wrote:
> Hello!
>
> Please review and sponsor the optimized implementation of
> Collections.nCopies().hashCode():
> https://bugs.openjdk.java.net/browse/JDK-8214687
> http://cr.openjdk.java.net/~tvaleev/webrev/8214687/r1/
>
> Previous discussion thread:
> http://mail.openjdk.java.net/pipermail/core-libs-dev/2018-November/056843.html
>
> Thanks to Zheka Kozlov for the original proposal. Also thanks to Ivan
> Gerasimov for the simplification idea: (x & 0x8000_0000) != 0 => x <
> 0.
>
> With best regards,
> Tagir Valeev
>

-- 
With kind regards,
Ivan Gerasimov



More information about the core-libs-dev mailing list