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

Commit c639cb67 authored by Philip P. Moltmann's avatar Philip P. Moltmann Committed by gitbuildkicker
Browse files

Do not write if apply() did not change the file.

Bug: 33385963
Test: SharedPreferences CTS tests
Change-Id: I39955f8fbcdaa54faa539a3c503e12cb00808136
(cherry picked from commit 1f99f81b)
parent 06276708
Loading
Loading
Loading
Loading
+10 −10
Original line number Diff line number Diff line
@@ -592,20 +592,20 @@ final class SharedPreferencesImpl implements SharedPreferences {
        if (mFile.exists()) {
            boolean needsWrite = false;

            if (isFromSyncCommit) {
            // Only need to write if the disk state is older than this commit
            if (mDiskStateGeneration < mcr.memoryStateGeneration) {
                if (isFromSyncCommit) {
                    needsWrite = true;
                }
                } else {
                    synchronized (this) {
                    // No need to persist intermediate states. Just wait for the latest state to be
                    // persisted.
                        // No need to persist intermediate states. Just wait for the latest state to
                        // be persisted.
                        if (mCurrentMemoryStateGeneration == mcr.memoryStateGeneration) {
                            needsWrite = true;
                        }
                    }
                }
            }

            if (!needsWrite) {
                if (DEBUG) {