summaryrefslogtreecommitdiffstats
path: root/base
diff options
context:
space:
mode:
Diffstat (limited to 'base')
-rw-r--r--base/values.cc11
1 files changed, 6 insertions, 5 deletions
diff --git a/base/values.cc b/base/values.cc
index 60b0d70..4719741 100644
--- a/base/values.cc
+++ b/base/values.cc
@@ -412,12 +412,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.
- if (HasKey(key)) {
- DCHECK(dictionary_[key] != in_value); // This would be bogus
- delete dictionary_[key];
+ std::pair<ValueMap::iterator, bool> ins_res =
+ dictionary_.insert(std::make_pair(key, in_value));
+ 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;
}
-
- dictionary_[key] = in_value;
}
bool DictionaryValue::Get(const std::string& path, Value** out_value) const {