Skip to content

Commit

Permalink
Simplify comparators in GcEvent
Browse files Browse the repository at this point in the history
Simplify TIME_ORDER and REVERSE_TIME_ORDER comparators by leveraging
Comparator.comparing and .reversed.
  • Loading branch information
kilink committed Oct 31, 2023
1 parent d5b30df commit 6533297
Showing 1 changed file with 2 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,8 @@ public String toString() {
}

/** Order events from oldest to newest. */
public static final Comparator<GcEvent> TIME_ORDER =
(e1, e2) -> (int) (e1.getStartTime() - e2.getStartTime());
public static final Comparator<GcEvent> TIME_ORDER = Comparator.comparing(GcEvent::getStartTime);

/** Order events from newest to oldest. */
public static final Comparator<GcEvent> REVERSE_TIME_ORDER =
(e1, e2) -> (int) (e2.getStartTime() - e1.getStartTime());
public static final Comparator<GcEvent> REVERSE_TIME_ORDER = TIME_ORDER.reversed();
}

0 comments on commit 6533297

Please sign in to comment.