Skip to content

Commit

Permalink
Simplify comparators in GcEvent (#1090)
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 authored Oct 31, 2023
1 parent 018fd70 commit b66ac26
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 b66ac26

Please sign in to comment.