Merge "Do not write if apply() did not change the file. am: ea10cc0fbb" into nyc-mr2-dev-plus-aosp

This commit is contained in:
Android Build Merger (Role)
2016-12-14 18:23:10 +00:00
committed by Android (Google) Code Review

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;
}
}
}
}