Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(802)

Unified Diff: base/prefs/default_pref_store.cc

Issue 11358123: Rewrite DefaultPrefStore for performance (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: base/prefs/default_pref_store.cc
diff --git a/base/prefs/default_pref_store.cc b/base/prefs/default_pref_store.cc
index c031221496e54eeb89601c87ba09259ccf387ebc..8b5f7e61bab1cbb9cd34b24c916f78c24999faf7 100644
--- a/base/prefs/default_pref_store.cc
+++ b/base/prefs/default_pref_store.cc
@@ -8,14 +8,26 @@ using base::Value;
DefaultPrefStore::DefaultPrefStore() {}
+PrefStore::ReadResult DefaultPrefStore::GetValue(
+ const std::string& key,
+ const base::Value** result) const {
+ const const_iterator entry = prefs_.find(key);
Bernhard Bauer 2012/11/06 18:25:02 Nit: I think a const const_iterator is overkill ;-
Mattias Nissler (ping if slow) 2012/11/07 08:24:02 It's correct w.r.t. the style guide though.
Anthony Berent 2012/11/07 11:22:54 This code actually goes away as a result of Mattla
+ if (entry != prefs_.end()) {
+ if (result)
+ *result = entry->second;
+ return READ_OK;
+ }
+ return READ_NO_VALUE;
+}
+
void DefaultPrefStore::SetDefaultValue(const std::string& key, Value* value) {
CHECK(GetValue(key, NULL) == READ_NO_VALUE);
- SetValue(key, value);
+ prefs_.insert(std::make_pair(key, value));
}
void DefaultPrefStore::RemoveDefaultValue(const std::string& key) {
CHECK(GetValue(key, NULL) == READ_OK);
- RemoveValue(key);
+ prefs_.erase(key);
}
base::Value::Type DefaultPrefStore::GetType(const std::string& key) const {
@@ -23,4 +35,12 @@ base::Value::Type DefaultPrefStore::GetType(const std::string& key) const {
return GetValue(key, &value) == READ_OK ? value->GetType() : Value::TYPE_NULL;
}
+DefaultPrefStore::const_iterator DefaultPrefStore::begin() const {
+ return prefs_.begin();
+}
+
+DefaultPrefStore::const_iterator DefaultPrefStore::end() const {
+ return prefs_.end();
+}
+
DefaultPrefStore::~DefaultPrefStore() {}

Powered by Google App Engine
This is Rietveld 408576698