RFR(s): JDK-8214687 Optimize Collections.nCopies().hashCode()
Zheka Kozlov
orionllmain at gmail.com
Mon Dec 3 08:42:37 UTC 2018
> Would it make sense to use CopiesList only for n > 0
This can break serialization. When CopiesList(0, e) is serialized and
deserialized back, it will be in an invalid state.
> I believe it makes sense to override CopiesList.equals()
Also: contains(), iterator(), listIterator()
пн, 3 дек. 2018 г. в 14:19, Ivan Gerasimov <ivan.gerasimov at oracle.com>:
> 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