Skip to content

Commit 9982f8e

Browse files
[lldb][SymbolFileDWARF][NFC] Remove unnecessary calls to GetDWARFDeclContext (#74523)
The function FindDefinitionTypeForDWARFDeclContext loops over all DIEs corresponding to types with a certain name and compares the context of each found DIE with the context of a target DIE. However, the target DIE never changes throughout this search, and yet we recompute its DeclContext on every iteration of the search. This is wasteful because the method is not exactly free (see DWARFDebugInfoEntry::GetDWARFDeclContextStatic).
1 parent 45e7b41 commit 9982f8e

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3120,7 +3120,8 @@ SymbolFileDWARF::FindDefinitionTypeForDWARFDeclContext(const DWARFDIE &die) {
31203120
template_params = dwarf_ast->GetDIEClassTemplateParams(die);
31213121
}
31223122

3123-
m_index->GetTypes(GetDWARFDeclContext(die), [&](DWARFDIE type_die) {
3123+
const DWARFDeclContext die_dwarf_decl_ctx = GetDWARFDeclContext(die);
3124+
m_index->GetTypes(die_dwarf_decl_ctx, [&](DWARFDIE type_die) {
31243125
// Make sure type_die's language matches the type system we are
31253126
// looking for. We don't want to find a "Foo" type from Java if we
31263127
// are looking for a "Foo" type for C, C++, ObjC, or ObjC++.
@@ -3184,7 +3185,7 @@ SymbolFileDWARF::FindDefinitionTypeForDWARFDeclContext(const DWARFDIE &die) {
31843185
}
31853186

31863187
// Make sure the decl contexts match all the way up
3187-
if (GetDWARFDeclContext(die) != type_dwarf_decl_ctx)
3188+
if (die_dwarf_decl_ctx != type_dwarf_decl_ctx)
31883189
return true;
31893190

31903191
Type *resolved_type = ResolveType(type_die, false);

0 commit comments

Comments
 (0)