Integrated: 8274319: Replace usages of Collections.sort with List.sort call in jdk.jfr

Andrey Turbanov duke at openjdk.java.net
Wed Dec 1 11:12:37 UTC 2021


On Sat, 25 Sep 2021 11:08:16 GMT, Andrey Turbanov <duke at openjdk.java.net> wrote:

> Collections.sort is just a wrapper, so it is better to use an instance method directly.
> 
> Also Comparator's implementation can be cleaned up with help of static methods in `Comparator` class.
> E.g.
> 
>         Collections.sort(sorted, new Comparator<EventType>() {
>             @Override
>             public int compare(EventType e1, EventType e2) {
>                 return e1.getName().compareTo(e2.getName());
>             }
>         });
> 
> can be replaced with
> 
> sorted.sort(Comparator.comparing(EventType::getName));

This pull request has now been integrated.

Changeset: 0c29ee50
Author:    Andrey Turbanov <turbanoff at gmail.com>
Committer: Erik Gahlin <egahlin at openjdk.org>
URL:       https://git.openjdk.java.net/jdk/commit/0c29ee50f07aa003f7cdaaa54f96b5c75b1f04db
Stats:     29 lines in 10 files changed: 1 ins; 11 del; 17 mod

8274319: Replace usages of Collections.sort with List.sort call in jdk.jfr

Reviewed-by: egahlin

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

PR: https://git.openjdk.java.net/jdk/pull/5696


More information about the hotspot-jfr-dev mailing list