RFR: 8371164: ArrayList.addAll() optimizations [v2]

jengebr duke at openjdk.org
Tue Nov 4 20:40:48 UTC 2025


On Tue, 4 Nov 2025 20:18:20 GMT, Claes Redestad <redestad at openjdk.org> wrote:

>> No, ArrayList.addAll(LinkedList).  This is the slow path that ideally will perform the same as before this change - and the initial change achieves that.  Rewriting to reduce duplication increased runtime of both the optimized and control.
>> 
>> I'll benchmark your suggestion as well.
>
> That variant is incorrect since `size <= a.length`, potentially adding a surprising tail of `null` elements to the list.

Thank you both!  @cl4es splitting it out had zero performance impact (per the benchmark).  As you said, it's a bit subjective... how strongly do you feel?  Other opinions are welcome too.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/28116#discussion_r2491983023


More information about the core-libs-dev mailing list