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

Commit a3a1f591 authored by Brad Fitzpatrick's avatar Brad Fitzpatrick Committed by Android (Google) Code Review
Browse files

Merge "Don't re-read SharedPreferences unnecessarily."

parents 55073498 5913630e
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -575,7 +575,8 @@ class ContextImpl extends Context {
            }

            Map map = null;
            if (prefsFile.exists() && prefsFile.canRead()) {
            FileStatus stat = new FileStatus();
            if (FileUtils.getFileStatus(prefsFile.getPath(), stat) && prefsFile.canRead()) {
                try {
                    FileInputStream str = new FileInputStream(prefsFile);
                    map = XmlUtils.readMapXml(str);
@@ -588,7 +589,7 @@ class ContextImpl extends Context {
                    Log.w(TAG, "getSharedPreferences", e);
                }
            }
            sp.replace(map);
            sp.replace(map, stat);
        }
        return sp;
    }
+5 −1
Original line number Diff line number Diff line
@@ -103,12 +103,16 @@ final class SharedPreferencesImpl implements SharedPreferences {
        }
    }

    public void replace(Map newContents) {
    /*package*/ void replace(Map newContents, FileStatus stat) {
        synchronized (this) {
            mLoaded = true;
            if (newContents != null) {
                mMap = newContents;
            }
            if (stat != null) {
                mStatTimestamp = stat.mtime;
                mStatSize = stat.size;
            }
        }
    }