RFR: 8327858: Improve spliterator and forEach for single-element immutable collections [v2]

Chen Liang liach at openjdk.org
Fri Apr 26 22:27:23 UTC 2024


On Tue, 23 Apr 2024 13:13:03 GMT, Per Minborg <pminborg at openjdk.org> wrote:

>> Chen Liang has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains 13 commits:
>> 
>>  - Use the improved form in forEach
>>  - Merge branch 'master' of https://github.com/openjdk/jdk into feature/imm-coll-stream
>>  - Null checks should probably be in the beginning...
>>  - mark implicit null checks
>>  - Merge branch 'master' of https://github.com/openjdk/jdk into feature/imm-coll-stream
>>  - Copyright year, revert changes for non-few element collections
>>  - Merge branch 'master' of https://github.com/openjdk/jdk into feature/imm-coll-stream
>>  - Merge branch 'feature/imm-coll-stream' of https://github.com/liachmodded/jdk into feature/imm-coll-stream
>>  - Spliterator for 12, iterate/forEach benchmark
>>  - fix comments
>>  - ... and 3 more: https://git.openjdk.org/jdk/compare/d5b95a0e...69bd0e9c
>
> Do we need additional tests or are these modifications already covered by the existing tests?

@minborg I have added a test as part of Collection mother-of-all-tests to ensure spliterator and forEach yields in the same order as iterator for unmodifiable/immutable collections. One thing of note is that somehow `==` for yields fail for some collections like `unmodifiableSequencedMap(linkedHashSet).sequencedKeySet()` so I have to use `Objects.equals` instead.

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

PR Comment: https://git.openjdk.org/jdk/pull/15834#issuecomment-2080179982


More information about the core-libs-dev mailing list