Index: include/lldb/Symbol/CompileUnit.h =================================================================== --- include/lldb/Symbol/CompileUnit.h +++ include/lldb/Symbol/CompileUnit.h @@ -18,6 +18,8 @@ #include "lldb/Utility/UserID.h" #include "lldb/lldb-enumerations.h" +#include "llvm/ADT/DenseMap.h" + namespace lldb_private { //---------------------------------------------------------------------- /// @class CompileUnit CompileUnit.h "lldb/Symbol/CompileUnit.h" @@ -418,6 +420,9 @@ std::vector m_functions; ///< The sparsely populated list of ///shared pointers to functions ///< that gets populated as functions get partially parsed. + + /// Maps function UIDs to indexes in m_functions. + llvm::DenseMap m_function_uid_to_index; std::vector m_imported_modules; ///< All modules, including the ///current module, imported by ///this Index: source/Symbol/CompileUnit.cpp =================================================================== --- source/Symbol/CompileUnit.cpp +++ source/Symbol/CompileUnit.cpp @@ -106,6 +106,7 @@ // Add a function to this compile unit //---------------------------------------------------------------------- void CompileUnit::AddFunction(FunctionSP &funcSP) { + m_function_uid_to_index[funcSP->GetID()] = m_functions.size(); // TODO: order these by address m_functions.push_back(funcSP); } @@ -163,18 +164,10 @@ //} FunctionSP CompileUnit::FindFunctionByUID(lldb::user_id_t func_uid) { - FunctionSP funcSP; - if (!m_functions.empty()) { - std::vector::const_iterator pos; - std::vector::const_iterator end = m_functions.end(); - for (pos = m_functions.begin(); pos != end; ++pos) { - if ((*pos)->GetID() == func_uid) { - funcSP = *pos; - break; - } - } - } - return funcSP; + auto it = m_function_uid_to_index.find(func_uid); + if (it == m_function_uid_to_index.end()) + return FunctionSP(); + return m_functions[it->second]; } lldb::LanguageType CompileUnit::GetLanguage() {