RFR: 8215995: Add specialized toArray methods to immutable collections
Martin Buchholz
martinrb at google.com
Wed Jan 2 19:26:20 UTC 2019
On Wed, Jan 2, 2019 at 11:10 AM Claes Redestad <claes.redestad at oracle.com>
wrote:
>
> > I was surprised by the use of SALT in SetN. I'm guessing you could
> > improve SetN by adapting the tricky circular array traversal code from
> > ArrayDeque.
> > I'm not convinced that the extra non-determinism from negative SALT
> > pulls its weight.
>
> This is one of Stuart's designs - the goal being to avoid
> situations where tests and production code create an unintended
> dependency on the iteration order - giving us more freedom to change
> hash algorithm etc. Since the SALT is calculated only once the untaken
> paths should be DCE'd, so we're not paying any real cost for this.
>
>
you could elide the creation of an Iterator object in toArray.
you could elide the bounds check on the second leg of the iteration if you
rewrote the loop in ArrayDeque style.
But on modern hardware with a modern JIT you might not even notice.
More information about the core-libs-dev
mailing list