[External] : RFD: Specializing ArrayDeque copy constructor for ArrayDeque (and possibly ArrayList)

Eirik Bjørsnøs eirbjo at gmail.com
Wed Feb 25 15:08:57 UTC 2026


Hi,

While looking into ArrayDeque::addElements recently, I noticed that the
copy constructor ArrayDeque(Collection) does not specialize for an
ArrayDeque being passed in a similar fashion to what ArrayList does.

By utilizing the ArrayListBulkOpsBenchmark and adopting it for ArrayDeque,
I was able to test the performance impact of specializing
ArrayDeque(Collection) for ArrayDeque.

Results show a reduction in time/op ranging from 30% (1 element) to 75% (75
elements).

I also experimented with a similar specialization for ArrayList which shows
promising results, up to 50% faster for lists of size 75.

However, there are many collections in the JDK and which combinations to
specialize for is not obvious. Is further exploration here worthwhile?

Cheers,
Eirik.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/core-libs-dev/attachments/20260225/77d73806/attachment-0001.htm>


More information about the core-libs-dev mailing list