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