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

Commit 6e8b38a2 authored by Christopher Tate's avatar Christopher Tate
Browse files

Eliminate redundant churn in SharedPreferences

Don't clone-then-discard, just work from what we have already, and start
fresh for potential new work.

Bug: 161534313
Test: atest android.content.cts.SharedPreferencesTest
Change-Id: I6edb2b09537f5e77cc2ad3e4d2f32a89b945ad80
parent 7be38456
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -80,7 +80,7 @@ public class QueuedWork {

    /** Work queued via {@link #queue} */
    @GuardedBy("sLock")
    private static final LinkedList<Runnable> sWork = new LinkedList<>();
    private static LinkedList<Runnable> sWork = new LinkedList<>();

    /** If new work can be delayed or not */
    @GuardedBy("sLock")
@@ -252,8 +252,8 @@ public class QueuedWork {
            LinkedList<Runnable> work;

            synchronized (sLock) {
                work = (LinkedList<Runnable>) sWork.clone();
                sWork.clear();
                work = sWork;
                sWork = new LinkedList<>();

                // Remove all msg-s as all work will be processed now
                getHandler().removeMessages(QueuedWorkHandler.MSG_RUN);