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

Unified Diff: snapshot/mac/mach_o_image_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_reader.cc
diff --git a/snapshot/mac/mach_o_image_reader.cc b/snapshot/mac/mach_o_image_reader.cc
index f9da354da81ffee01bd150bcd9d7f00b71b18b11..cb85baabfd9ad4ed39726832e45e820a4cc26a67 100644
--- a/snapshot/mac/mach_o_image_reader.cc
+++ b/snapshot/mac/mach_o_image_reader.cc
@@ -20,6 +20,7 @@
#include <limits>
#include <vector>
+#include <utility>
#include "base/logging.h"
#include "base/strings/stringprintf.h"
@@ -543,15 +544,15 @@ bool MachOImageReader::ReadSegmentCommand(
// become inconsistent or require cleanup.
const std::string segment_name = segment->Name();
- const auto& iterator = segment_map_.find(segment_name);
- if (iterator != segment_map_.end()) {
+ const auto insert_result =
+ segment_map_.insert(std::make_pair(segment_name, segment_index));
+ if (!insert_result.second) {
LOG(WARNING) << base::StringPrintf("duplicate %s segment at %zu and %zu",
segment_name.c_str(),
- iterator->second,
+ insert_result.first->second,
segment_index) << load_command_info;
return false;
}
- segment_map_[segment_name] = segment_index;
mach_vm_size_t vmsize = segment->vmsize();

Powered by Google App Engine
This is Rietveld 408576698