From 50b3d507bdbc69ea12c19a3b7ba89970db15afae Mon Sep 17 00:00:00 2001 From: Jim Ingham Date: Thu, 12 Jan 2012 22:35:29 +0000 Subject: [PATCH] Let the Module FindType do the stripping of namespace components, that's not expensive and doing it both at the ModuleList and Module levels means we look 4 times for a negative search. Also, don't do the search for the stripped name if that is the same as the original one. llvm-svn: 148054 --- lldb/include/lldb/Core/ModuleList.h | 7 ------ lldb/source/Core/Module.cpp | 9 +++++-- lldb/source/Core/ModuleList.cpp | 37 +---------------------------- 3 files changed, 8 insertions(+), 45 deletions(-) diff --git a/lldb/include/lldb/Core/ModuleList.h b/lldb/include/lldb/Core/ModuleList.h index 213208ded899..1e59e21ad12d 100644 --- a/lldb/include/lldb/Core/ModuleList.h +++ b/lldb/include/lldb/Core/ModuleList.h @@ -434,13 +434,6 @@ protected: collection m_modules; ///< The collection of modules. mutable Mutex m_modules_mutex; -private: - uint32_t - FindTypes_Impl (const SymbolContext& sc, - const ConstString &name, - bool append, - uint32_t max_matches, - TypeList& types); }; } // namespace lldb_private diff --git a/lldb/source/Core/Module.cpp b/lldb/source/Core/Module.cpp index 8dc755b8d146..ea16376aa340 100644 --- a/lldb/source/Core/Module.cpp +++ b/lldb/source/Core/Module.cpp @@ -531,8 +531,13 @@ Module::FindTypes (const SymbolContext& sc, const ConstString &name, const Clan if (retval == 0) { - const char *stripped = StripTypeName(name.GetCString()); - return FindTypes_Impl(sc, ConstString(stripped), namespace_decl, append, max_matches, types); + const char *orig_name = name.GetCString(); + const char *stripped = StripTypeName(orig_name); + // Only do this lookup if StripTypeName has stripped the name: + if (stripped != orig_name) + return FindTypes_Impl(sc, ConstString(stripped), namespace_decl, append, max_matches, types); + else + return 0; } else return retval; diff --git a/lldb/source/Core/ModuleList.cpp b/lldb/source/Core/ModuleList.cpp index 339e460f911f..5846d8155a0d 100644 --- a/lldb/source/Core/ModuleList.cpp +++ b/lldb/source/Core/ModuleList.cpp @@ -434,7 +434,7 @@ ModuleList::FindModule (const UUID &uuid) uint32_t -ModuleList::FindTypes_Impl (const SymbolContext& sc, const ConstString &name, bool append, uint32_t max_matches, TypeList& types) +ModuleList::FindTypes (const SymbolContext& sc, const ConstString &name, bool append, uint32_t max_matches, TypeList& types) { Mutex::Locker locker(m_modules_mutex); @@ -454,41 +454,6 @@ ModuleList::FindTypes_Impl (const SymbolContext& sc, const ConstString &name, bo return total_matches; } -// depending on implementation details, type lookup might fail because of -// embedded spurious namespace:: prefixes. this call strips them, paying -// attention to the fact that a type might have namespace'd type names as -// arguments to templates, and those must not be stripped off -static const char* -StripTypeName(const char* name_cstr) -{ - const char* skip_namespace = strstr(name_cstr, "::"); - const char* template_arg_char = strchr(name_cstr, '<'); - while (skip_namespace != NULL) - { - if (template_arg_char != NULL && - skip_namespace > template_arg_char) // but namespace'd template arguments are still good to go - break; - name_cstr = skip_namespace+2; - skip_namespace = strstr(name_cstr, "::"); - } - return name_cstr; -} - -uint32_t -ModuleList::FindTypes (const SymbolContext& sc, const ConstString &name, bool append, uint32_t max_matches, TypeList& types) -{ - uint32_t retval = FindTypes_Impl(sc, name, append, max_matches, types); - - if (retval == 0) - { - const char *stripped = StripTypeName(name.GetCString()); - return FindTypes_Impl(sc, ConstString(stripped), append, max_matches, types); - } - else - return retval; - -} - ModuleSP ModuleList::FindFirstModuleForFileSpec (const FileSpec &file_spec, const ArchSpec *arch_ptr,