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

Unified Diff: tools/mac/run_with_crashpad.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: tools/mac/run_with_crashpad.cc
diff --git a/tools/mac/run_with_crashpad.cc b/tools/mac/run_with_crashpad.cc
index 9d6679cff22380ebf26bc2e672f454de14743ab1..0b4653aa20caf9314dfc9390d90a91d35ea9e9f3 100644
--- a/tools/mac/run_with_crashpad.cc
+++ b/tools/mac/run_with_crashpad.cc
@@ -27,6 +27,7 @@
#include "base/logging.h"
#include "client/crashpad_client.h"
#include "tools/tool_support.h"
+#include "util/stdlib/map_insert.h"
#include "util/string/split_string.h"
namespace crashpad {
@@ -118,13 +119,10 @@ int RunWithCrashpadMain(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