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

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

Merge "[don't auto-merge] Don't re-read SharedPreferences unnecessarily." into gingerbread

parents 06e8cdc0 d2bbaaf2
Loading
Loading
Loading
Loading
+8 −3
Original line number Diff line number Diff line
@@ -367,7 +367,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);
@@ -380,7 +381,7 @@ class ContextImpl extends Context {
                    Log.w(TAG, "getSharedPreferences", e);
                }
            }
            sp.replace(map);
            sp.replace(map, stat);
        }
        return sp;
    }
@@ -2768,12 +2769,16 @@ class ContextImpl extends Context {
            }
        }

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