Index: handler/mac/crash_report_upload_thread.cc |
diff --git a/handler/mac/crash_report_upload_thread.cc b/handler/mac/crash_report_upload_thread.cc |
index 5333c78d180e02d476dfb4a3434515220363e0a2..e266b7f764f4ff57a70beab323c255a45e2b3b93 100644 |
--- a/handler/mac/crash_report_upload_thread.cc |
+++ b/handler/mac/crash_report_upload_thread.cc |
@@ -19,7 +19,6 @@ |
#include <map> |
#include <vector> |
-#include <utility> |
#include "base/logging.h" |
#include "base/memory/scoped_ptr.h" |
@@ -31,6 +30,7 @@ |
#include "util/net/http_body.h" |
#include "util/net/http_multipart_builder.h" |
#include "util/net/http_transport.h" |
+#include "util/stdlib/map_insert.h" |
namespace crashpad { |
@@ -39,13 +39,10 @@ namespace { |
void InsertOrReplaceMapEntry(std::map<std::string, std::string>* map, |
const std::string& key, |
const std::string& value) { |
- auto it = map->find(key); |
- if (it != map->end()) { |
+ std::string old_value; |
+ if (!MapInsertOrReplace(map, key, value, &old_value)) { |
LOG(WARNING) << "duplicate key " << key << ", discarding value " |
- << it->second; |
- it->second = value; |
- } else { |
- map->insert(std::make_pair(key, value)); |
+ << old_value; |
} |
} |
@@ -75,11 +72,9 @@ std::map<std::string, std::string> BreakpadHTTPFormParametersFromMinidump( |
std::string list_annotations; |
for (const ModuleSnapshot* module : minidump_process_snapshot.Modules()) { |
for (const auto& kv : module->AnnotationsSimpleMap()) { |
- if (parameters.find(kv.first) != parameters.end()) { |
+ if (!parameters.insert(kv).second) { |
LOG(WARNING) << "duplicate key " << kv.first << ", discarding value " |
<< kv.second; |
- } else { |
- parameters.insert(kv); |
} |
} |