RFR: 8362958: Unnecessary copying / sorting in Streams using Comparator.naturalOrder() [v2]
Patrick Strawderman
duke at openjdk.org
Tue Nov 11 16:34:23 UTC 2025
On Tue, 11 Nov 2025 14:32:20 GMT, Viktor Klang <vklang at openjdk.org> wrote:
>> Patrick Strawderman has updated the pull request incrementally with one additional commit since the last revision:
>>
>> Update src/java.base/share/classes/java/util/stream/StreamOpFlag.java
>>
>> Simplify comparison
>>
>> Co-authored-by: Viktor Klang <viktor.klang at oracle.com>
>
> src/java.base/share/classes/java/util/stream/SortedOps.java line 64:
>
>> 62: Comparator<? super T> comparator) {
>> 63: return Comparator.naturalOrder().equals(comparator) ?
>> 64: new OfRef<>(upstream) : new OfRef<>(upstream, comparator);
>
> I think it would be better to address this directly in the OfRef constructor, and let the 1-arg constructor delegate to the 2-arg constructor.
I had originally tried that approach, let me go back to it.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/28226#discussion_r2514896974
More information about the core-libs-dev
mailing list