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

Unified Diff: handler/mac/crash_report_upload_thread.cc

Issue 1044273002: Improve map insertions (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: Created 5 years, 9 months 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
« no previous file with comments | « no previous file | handler/mac/main.cc » ('j') | snapshot/minidump/minidump_simple_string_dictionary_reader.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
}
}
« no previous file with comments | « no previous file | handler/mac/main.cc » ('j') | snapshot/minidump/minidump_simple_string_dictionary_reader.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698