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

am: 1f99f81bdc

Change-Id: I4dd94b4f862f6c3d5ada9961d75cc2f91886edf1
This commit is contained in:
Philip P. Moltmann
2017-01-13 01:10:01 +00:00
committed by android-build-merger

View File

@@ -592,17 +592,17 @@ 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) {
// 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.
if (mCurrentMemoryStateGeneration == mcr.memoryStateGeneration) {
needsWrite = true;
} else {
synchronized (this) {
// No need to persist intermediate states. Just wait for the latest state to
// be persisted.
if (mCurrentMemoryStateGeneration == mcr.memoryStateGeneration) {
needsWrite = true;
}
}
}
}