Do not write if apply() did not change the file.
Bug: 33385963 Test: SharedPreferences CTS tests Change-Id: I39955f8fbcdaa54faa539a3c503e12cb00808136
This commit is contained in:
committed by
Svetoslav Ganov
parent
d15c4f1da5
commit
1f99f81bdc
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user