[Lldb-commits] [lldb] c7738cc - [lldb] Don't search the metadata map three times when retrieving metadata
Raphael Isemann via lldb-commits
lldb-commits at lists.llvm.org
Wed Dec 11 06:08:58 PST 2019
Author: Raphael Isemann
Date: 2019-12-11T15:08:10+01:00
New Revision: c7738cca7efda9d1a78569b69ba4ac735c0f2212
URL: https://github.com/llvm/llvm-project/commit/c7738cca7efda9d1a78569b69ba4ac735c0f2212
DIFF: https://github.com/llvm/llvm-project/commit/c7738cca7efda9d1a78569b69ba4ac735c0f2212.diff
LOG: [lldb] Don't search the metadata map three times when retrieving metadata
HasMetadata checks if our metadata map knows the given object. GetMetadata
also does this check and then does another search to actually retrieve
the value. This can all just be one lookup.
Added:
Modified:
lldb/include/lldb/Symbol/ClangExternalASTSourceCommon.h
lldb/source/Symbol/ClangASTContext.cpp
lldb/source/Symbol/ClangExternalASTSourceCommon.cpp
Removed:
################################################################################
diff --git a/lldb/include/lldb/Symbol/ClangExternalASTSourceCommon.h b/lldb/include/lldb/Symbol/ClangExternalASTSourceCommon.h
index 8e69f6d3e4eb..1d40080033a1 100644
--- a/lldb/include/lldb/Symbol/ClangExternalASTSourceCommon.h
+++ b/lldb/include/lldb/Symbol/ClangExternalASTSourceCommon.h
@@ -128,7 +128,6 @@ class ClangExternalASTSourceCommon : public clang::ExternalASTSource {
ClangASTMetadata *GetMetadata(const void *object);
void SetMetadata(const void *object, ClangASTMetadata &metadata);
- bool HasMetadata(const void *object);
static ClangExternalASTSourceCommon *Lookup(clang::ExternalASTSource *source);
diff --git a/lldb/source/Symbol/ClangASTContext.cpp b/lldb/source/Symbol/ClangASTContext.cpp
index 8c5b0cae34b7..e7237a39a9c2 100644
--- a/lldb/source/Symbol/ClangASTContext.cpp
+++ b/lldb/source/Symbol/ClangASTContext.cpp
@@ -2419,7 +2419,7 @@ ClangASTMetadata *ClangASTContext::GetMetadata(clang::ASTContext *ast,
ClangExternalASTSourceCommon *external_source =
ClangExternalASTSourceCommon::Lookup(ast->getExternalSource());
- if (external_source && external_source->HasMetadata(object))
+ if (external_source)
return external_source->GetMetadata(object);
else
return nullptr;
diff --git a/lldb/source/Symbol/ClangExternalASTSourceCommon.cpp b/lldb/source/Symbol/ClangExternalASTSourceCommon.cpp
index 9c58969dc46e..b60b3791aae1 100644
--- a/lldb/source/Symbol/ClangExternalASTSourceCommon.cpp
+++ b/lldb/source/Symbol/ClangExternalASTSourceCommon.cpp
@@ -53,8 +53,9 @@ ClangExternalASTSourceCommon::~ClangExternalASTSourceCommon() {
ClangASTMetadata *
ClangExternalASTSourceCommon::GetMetadata(const void *object) {
- if (HasMetadata(object))
- return &m_metadata[object];
+ auto It = m_metadata.find(object);
+ if (It != m_metadata.end())
+ return &It->second;
else
return nullptr;
}
@@ -64,10 +65,6 @@ void ClangExternalASTSourceCommon::SetMetadata(const void *object,
m_metadata[object] = metadata;
}
-bool ClangExternalASTSourceCommon::HasMetadata(const void *object) {
- return m_metadata.find(object) != m_metadata.end();
-}
-
void ClangASTMetadata::Dump(Stream *s) {
lldb::user_id_t uid = GetUserID();
More information about the lldb-commits
mailing list