Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 788708ce authored by Kweku Adams's avatar Kweku Adams
Browse files

Use common Comparator.

Every AlarmPriorityQueue will use the exact same comparator, so there's
no point creating a new one for each instance.

Bug: 247097209
Test: atest FrameworksMockingServicesTests:AlarmQueueTest
Change-Id: I8e07157fef57f6047414e9c8b46da0dac91c6714
parent 5cb56048
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -64,8 +64,11 @@ public abstract class AlarmQueue<K> implements AlarmManager.OnAlarmListener {
     * The pair is the key and its associated alarm time (in the elapsed realtime timebase).
     */
    private static class AlarmPriorityQueue<Q> extends PriorityQueue<Pair<Q, Long>> {
        private static final Comparator<Pair<?, Long>> sTimeComparator =
                (o1, o2) -> Long.compare(o1.second, o2.second);

        AlarmPriorityQueue() {
            super(1, Comparator.comparingLong(o -> o.second));
            super(1, sTimeComparator);
        }

        /**