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

Johannes Döbler duke at openjdk.org
Tue Nov 4 19:04:10 UTC 2025


On Tue, 4 Nov 2025 14:56:08 GMT, jengebr <duke at openjdk.org> wrote:

>> src/java.base/share/classes/java/util/ArrayList.java line 758:
>> 
>>> 756:             int numNew = src.size;
>>> 757:             if (numNew == 0)
>>> 758:                 return false;
>> 
>> Previously `addAll()` with an empty list would increment `modCount`, whereas now it won't. Might want to move this test down after `modCount++` to avoid the unnecessary behavioral change.
>
> Will definitely fix, thank you for the catch!

> Previously addAll() with an empty list would increment modCount, 

which is unfortunate, since the list wasn't modified.

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

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


More information about the core-libs-dev mailing list