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

Unified Diff: snapshot/mac/mach_o_image_symbol_table_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_symbol_table_reader.cc
diff --git a/snapshot/mac/mach_o_image_symbol_table_reader.cc b/snapshot/mac/mach_o_image_symbol_table_reader.cc
index 12d8de7e2b718b6d2ce9ed4f46f0f8c00b4ebbc7..949e46088697241c5eebc77ab35199d9f9e13fd1 100644
--- a/snapshot/mac/mach_o_image_symbol_table_reader.cc
+++ b/snapshot/mac/mach_o_image_symbol_table_reader.cc
@@ -17,6 +17,8 @@
#include <mach-o/loader.h>
#include <mach-o/nlist.h>
+#include <utility>
+
#include "base/memory/scoped_ptr.h"
#include "base/strings/stringprintf.h"
#include "util/mac/checked_mach_address_range.h"
@@ -153,15 +155,14 @@ class MachOImageSymbolTableReaderInitializer {
return false;
}
- if (external_defined_symbols->count(name)) {
- LOG(WARNING) << "duplicate symbol " << name << symbol_info;
- return false;
- }
-
MachOImageSymbolTableReader::SymbolInformation this_symbol_info;
this_symbol_info.value = symbol.n_value;
this_symbol_info.section = symbol.n_sect;
- (*external_defined_symbols)[name] = this_symbol_info;
+ if (!external_defined_symbols->insert(
+ std::make_pair(name, this_symbol_info)).second) {
+ LOG(WARNING) << "duplicate symbol " << name << symbol_info;
+ return false;
+ }
} else {
// External indirect symbols may be found in the portion of the symbol
// table used for external symbols as opposed to indirect symbols when

Powered by Google App Engine
This is Rietveld 408576698