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

Unified Diff: base/values.cc

Issue 753603002: Change preference APIs to take std::string instead of const char*. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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
« base/prefs/pref_value_store.cc ('K') | « base/prefs/testing_pref_service.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/values.cc
diff --git a/base/values.cc b/base/values.cc
index 5d45ec36c5551b6e72083d1f5f5736d69dd5bebc..d60b6484586a829357eb9af3302f99e21e42491e 100644
--- a/base/values.cc
+++ b/base/values.cc
@@ -421,12 +421,13 @@ void DictionaryValue::SetWithoutPathExpansion(const std::string& key,
Value* in_value) {
// If there's an existing value here, we need to delete it, because
// we own all our children.
- std::pair<ValueMap::iterator, bool> ins_res =
- dictionary_.insert(std::make_pair(key, in_value));
Nico 2014/12/01 16:57:02 Isn't the lhs better here? It requires on-stack al
Georges Khalil 2014/12/01 20:34:11 I'm removing this code from the CL, because it doe
- if (!ins_res.second) {
- DCHECK_NE(ins_res.first->second, in_value); // This would be bogus
- delete ins_res.first->second;
- ins_res.first->second = in_value;
+ ValueMap::iterator it = dictionary_.find(key);
+ if (it == dictionary_.end()) {
+ dictionary_.insert(std::make_pair(key, in_value));
+ } else {
+ DCHECK_NE(it->second, in_value); // This would be bogus
+ delete it->second;
+ it->second = in_value;
}
}
« base/prefs/pref_value_store.cc ('K') | « base/prefs/testing_pref_service.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698