From 07ea010b9019c96f1a754a2a2ed73667ed7aead7 Mon Sep 17 00:00:00 2001 From: Adrian Prantl Date: Tue, 8 Oct 2019 16:59:24 +0000 Subject: ObjectFileMachO: Replace std::map with llvm::DenseMap (NFC) This makes parsing the symbol table of clang marginally faster. (Hashtable versus tree). Differential Revision: https://reviews.llvm.org/D68605 git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@374084 91177308-0d34-0410-b5e6-96231b3b80d8 --- .../Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp | 28 ++++++++-------------- 1 file changed, 10 insertions(+), 18 deletions(-) (limited to 'source') diff --git a/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp b/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp index 46177e7bb..be02eaec2 100644 --- a/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp +++ b/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp @@ -2478,8 +2478,8 @@ size_t ObjectFileMachO::ParseSymtab() { std::vector N_BRAC_indexes; std::vector N_COMM_indexes; typedef std::multimap ValueToSymbolIndexMap; - typedef std::map NListIndexToSymbolIndexMap; - typedef std::map ConstNameToSymbolIndexMap; + typedef llvm::DenseMap NListIndexToSymbolIndexMap; + typedef llvm::DenseMap ConstNameToSymbolIndexMap; ValueToSymbolIndexMap N_FUN_addr_to_sym_idx; ValueToSymbolIndexMap N_STSYM_addr_to_sym_idx; ConstNameToSymbolIndexMap N_GSYM_name_to_sym_idx; @@ -2689,8 +2689,8 @@ size_t ObjectFileMachO::ParseSymtab() { offset = 0; - typedef std::map UndefinedNameToDescMap; - typedef std::map SymbolIndexToName; + typedef llvm::DenseMap UndefinedNameToDescMap; + typedef llvm::DenseMap SymbolIndexToName; UndefinedNameToDescMap undefined_name_to_desc; SymbolIndexToName reexport_shlib_needs_fixup; @@ -3487,15 +3487,11 @@ size_t ObjectFileMachO::ParseSymtab() { // matches, then we can merge the two into just the // function symbol to avoid duplicate entries in // the symbol table - std::pair - range; - range = + auto range = N_FUN_addr_to_sym_idx.equal_range(nlist.n_value); if (range.first != range.second) { bool found_it = false; - for (ValueToSymbolIndexMap::const_iterator pos = - range.first; + for (const auto pos = range.first; pos != range.second; ++pos) { if (sym[sym_idx].GetMangled().GetName( lldb::eLanguageTypeUnknown, @@ -3536,15 +3532,11 @@ size_t ObjectFileMachO::ParseSymtab() { // matches, then we can merge the two into just the // Static symbol to avoid duplicate entries in the // symbol table - std::pair - range; - range = N_STSYM_addr_to_sym_idx.equal_range( + auto range = N_STSYM_addr_to_sym_idx.equal_range( nlist.n_value); if (range.first != range.second) { bool found_it = false; - for (ValueToSymbolIndexMap::const_iterator pos = - range.first; + for (const auto pos = range.first; pos != range.second; ++pos) { if (sym[sym_idx].GetMangled().GetName( lldb::eLanguageTypeUnknown, @@ -3667,8 +3659,8 @@ size_t ObjectFileMachO::ParseSymtab() { nlist_idx = 0; } - typedef std::map UndefinedNameToDescMap; - typedef std::map SymbolIndexToName; + typedef llvm::DenseMap UndefinedNameToDescMap; + typedef llvm::DenseMap SymbolIndexToName; UndefinedNameToDescMap undefined_name_to_desc; SymbolIndexToName reexport_shlib_needs_fixup; -- cgit v1.2.3