RFR: 8371164: ArrayList.addAll() optimizations [v2]
Johannes Döbler
duke at openjdk.org
Tue Nov 4 19:46:43 UTC 2025
On Tue, 4 Nov 2025 18:43:08 GMT, Claes Redestad <redestad at openjdk.org> wrote:
>> The comment is a good idea, but splitting out the duplication may make maintenance even worse by separating the duplicate sections. What do you think?
>>
>> Also, I'll benchmark with the split to get the impact data. Not sure I can meaningfully validate an impact to inlining.
>
> I think peeling off and outlining distinct paths in a larger method to separate, simpler methods usually reduces distracting noise and improves readability, but I guess that's subjective territory.
> cl4es: Consider simplifying this to reduce code duplication:
or even simpler?
Object[] a = c.getClass() == ArrayList.class ? ((ArrayList<?>)c).elementData : a.toArray();
int newNum = a.length;
...
> jengebr: Interestingly, this hurt the fast-path about 5%, but the control case about 35%.
what is the control case, LinkedList.addAll() ?
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/28116#discussion_r2491853221
More information about the core-libs-dev
mailing list