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

Unified Diff: snapshot/mac/mach_o_image_annotations_reader.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: snapshot/mac/mach_o_image_annotations_reader.cc
diff --git a/snapshot/mac/mach_o_image_annotations_reader.cc b/snapshot/mac/mach_o_image_annotations_reader.cc
index 4623aa63619544ad2c86764a7a648a17fd37b461..6c6831bdaea9b9616e4dca155e77f3e4fb37c1ab 100644
--- a/snapshot/mac/mach_o_image_annotations_reader.cc
+++ b/snapshot/mac/mach_o_image_annotations_reader.cc
@@ -17,6 +17,8 @@
#include <mach-o/loader.h>
#include <mach/mach.h>
+#include <utility>
+
#include "base/logging.h"
#include "client/crashpad_info.h"
#include "client/simple_string_dictionary.h"
@@ -161,10 +163,7 @@ void MachOImageAnnotationsReader::ReadCrashpadSimpleAnnotations(
if (key_length) {
std::string key(entry.key, key_length);
std::string value(entry.value, strnlen(entry.value, sizeof(entry.value)));
- if (!simple_map_annotations->count(key)) {
- simple_map_annotations->insert(
- std::pair<std::string, std::string>(key, value));
- } else {
+ if (!simple_map_annotations->insert(std::make_pair(key, value)).second) {
LOG(INFO) << "duplicate simple annotation " << key << " in " << name_;
}
}

Powered by Google App Engine
This is Rietveld 408576698