RFR: 8272992: Replace usages of Collections.sort with List.sort call in jdk.* modules [v2]
Andrey Turbanov
github.com+741251+turbanoff at openjdk.java.net
Tue Sep 14 07:46:14 UTC 2021
On Mon, 13 Sep 2021 17:58:02 GMT, Rémi Forax <forax at openjdk.org> wrote:
>> Andrey Turbanov has updated the pull request incrementally with one additional commit since the last revision:
>>
>> 8272992: Replace usages of Collections.sort with List.sort call in jdk.* modules
>
> src/jdk.jfr/share/classes/jdk/jfr/internal/dcmd/DCmdCheck.java line 137:
>
>> 135: List<EventType> sorted = new ArrayList<>();
>> 136: sorted.addAll(events);
>> 137: sorted.sort(new Comparator<EventType>() {
>
> I wonder if there is a bootstrap issue here (why an anonymous class is used instead of a lambda?)
> If a lambda can be used, it cn be simplified to
> `sorted.sort(Comparator.comparing(EventType::getName))`
As I can see lambdas are used in other places in this module. Replaced
> src/jdk.jfr/share/classes/jdk/jfr/internal/tool/Summary.java line 145:
>
>> 143: println(" Duration: " + (totalDuration + 500_000_000) / 1_000_000_000 + " s");
>> 144: List<Statistics> statsList = new ArrayList<>(stats.values());
>> 145: statsList.sort((u, v) -> Long.compare(v.count, u.count));
>
> `statsList.sort(Comparator.comparingLong(v -> v.count))`
replaced
-------------
PR: https://git.openjdk.java.net/jdk/pull/5230
More information about the javadoc-dev
mailing list