Do not write if apply() did not change the file. am: 1f99f81bdc
am: 331a4bb8d4
Change-Id: I068dcbfcdaffff85379d422a9c53aafe7caa01c2
This commit is contained in:
@@ -592,17 +592,17 @@ final class SharedPreferencesImpl implements SharedPreferences {
|
|||||||
if (mFile.exists()) {
|
if (mFile.exists()) {
|
||||||
boolean needsWrite = false;
|
boolean needsWrite = false;
|
||||||
|
|
||||||
if (isFromSyncCommit) {
|
// Only need to write if the disk state is older than this commit
|
||||||
// Only need to write if the disk state is older than this commit
|
if (mDiskStateGeneration < mcr.memoryStateGeneration) {
|
||||||
if (mDiskStateGeneration < mcr.memoryStateGeneration) {
|
if (isFromSyncCommit) {
|
||||||
needsWrite = true;
|
needsWrite = true;
|
||||||
}
|
} else {
|
||||||
} else {
|
synchronized (this) {
|
||||||
synchronized (this) {
|
// No need to persist intermediate states. Just wait for the latest state to
|
||||||
// No need to persist intermediate states. Just wait for the latest state to be
|
// be persisted.
|
||||||
// persisted.
|
if (mCurrentMemoryStateGeneration == mcr.memoryStateGeneration) {
|
||||||
if (mCurrentMemoryStateGeneration == mcr.memoryStateGeneration) {
|
needsWrite = true;
|
||||||
needsWrite = true;
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user