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

Unified Diff: snapshot/mac/mach_o_image_segment_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_segment_reader.cc
diff --git a/snapshot/mac/mach_o_image_segment_reader.cc b/snapshot/mac/mach_o_image_segment_reader.cc
index 6adcd6f2ef56a36da7949730793fec6197ccd554..8a077ddec036410e5ec373eb024c416712281d54 100644
--- a/snapshot/mac/mach_o_image_segment_reader.cc
+++ b/snapshot/mac/mach_o_image_segment_reader.cc
@@ -16,6 +16,8 @@
#include <mach-o/loader.h>
+#include <utility>
+
#include "base/logging.h"
#include "base/strings/stringprintf.h"
#include "snapshot/mac/process_reader.h"
@@ -185,14 +187,14 @@ bool MachOImageSegmentReader::Initialize(ProcessReader* process_reader,
return false;
}
- const auto& iterator = section_map_.find(section_name);
- if (iterator != section_map_.end()) {
+ const auto insert_result =
+ section_map_.insert(std::make_pair(section_name, section_index));
+ if (!insert_result.second) {
LOG(WARNING) << base::StringPrintf("duplicate section name at %zu",
- iterator->second) << section_info;
+ insert_result.first->second)
+ << section_info;
return false;
}
-
- section_map_[section_name] = section_index;
}
INITIALIZATION_STATE_SET_VALID(initialized_);

Powered by Google App Engine
This is Rietveld 408576698