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

Unified Diff: handler/mac/main.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
Index: handler/mac/main.cc
diff --git a/handler/mac/main.cc b/handler/mac/main.cc
index 1df183f94c924df92e7aba3105f2174d21ed193b..7f0629bbed890389966d2e5c2baaf2cd15b8742a 100644
--- a/handler/mac/main.cc
+++ b/handler/mac/main.cc
@@ -18,7 +18,6 @@
#include <map>
#include <string>
-#include <utility>
#include "base/files/file_path.h"
#include "base/logging.h"
@@ -30,6 +29,7 @@
#include "handler/mac/exception_handler_server.h"
#include "util/mach/child_port_handshake.h"
#include "util/posix/close_stdio.h"
+#include "util/stdlib/map_insert.h"
#include "util/stdlib/string_number_conversion.h"
#include "util/string/split_string.h"
#include "util/synchronization/semaphore.h"
@@ -97,13 +97,10 @@ int HandlerMain(int argc, char* argv[]) {
ToolSupport::UsageHint(me, "--annotation requires KEY=VALUE");
return EXIT_FAILURE;
}
- auto it = options.annotations.find(key);
- if (it != options.annotations.end()) {
+ std::string old_value;
+ if (!MapInsertOrReplace(&options.annotations, key, value, &old_value)) {
LOG(WARNING) << "duplicate key " << key << ", discarding value "
- << it->second;
- it->second = value;
- } else {
- options.annotations.insert(std::make_pair(key, value));
+ << old_value;
}
break;
}

Powered by Google App Engine
This is Rietveld 408576698