On Wed, 5 Nov 2025 05:23:37 GMT, Stuart Marks <[email protected]> wrote:
>> I would think that you need to check `src.modCount` has same value at start >> and end of the method. >> >> >> final int expectedSrcModCount = src.modCount; >> //access src internals.... >> checkForComodification(expectedSrcModCount) >> >> >> Looks like ArrayList::toArray is not doing this check either. So perhaps it >> is not needed. I would have thought mod check would have been needed in >> toArray to mimic iterator behavior. Therefore needed in addAll. > > I'd have to see the code with the split methods to know for sure, but if it > involves duplicating code, then I'd prefer to try harder to avoid the > duplication. What's the main optimization here? Direct access to the argument > ArrayList's array, avoiding an intermediate copy? If this is the case, then > it's hard to believe that it's necessary to duplicate the remainder of the > method, which does the growth and copying, which I think aren't changed by > this optimization. I just addressed this in a higher-level comment on this PR. I cannot reproduce the negative result, so proceeded with the simpler and less-duplicative code. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/28116#discussion_r2500662816
