mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 15:07:45 +00:00
LibDebug: Dont copy an AbbreviationEntry every time we retrieve a value
These API's are used in a variety of ways when building the die cache. Each AbbreviationEntry has vector and other members, so avoid copying it at all costs.
This commit is contained in:
parent
952441943f
commit
c5cdb6eb4c
3 changed files with 13 additions and 11 deletions
|
@ -66,9 +66,13 @@ void AbbreviationsMap::populate_map()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Optional<AbbreviationsMap::AbbreviationEntry> AbbreviationsMap::get(u32 code) const
|
AbbreviationsMap::AbbreviationEntry const* AbbreviationsMap::get(u32 code) const
|
||||||
{
|
{
|
||||||
return m_entries.get(code);
|
auto it = m_entries.find(code);
|
||||||
|
if (it == m_entries.end()) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
return &it->value;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,14 +20,12 @@ public:
|
||||||
AbbreviationsMap(DwarfInfo const& dwarf_info, u32 offset);
|
AbbreviationsMap(DwarfInfo const& dwarf_info, u32 offset);
|
||||||
|
|
||||||
struct AbbreviationEntry {
|
struct AbbreviationEntry {
|
||||||
|
|
||||||
EntryTag tag;
|
EntryTag tag;
|
||||||
bool has_children;
|
bool has_children;
|
||||||
|
|
||||||
Vector<AttributeSpecification> attribute_specifications;
|
Vector<AttributeSpecification> attribute_specifications;
|
||||||
};
|
};
|
||||||
|
AbbreviationEntry const* get(u32 code) const;
|
||||||
Optional<AbbreviationEntry> get(u32 code) const;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void populate_map();
|
void populate_map();
|
||||||
|
|
|
@ -32,13 +32,13 @@ void DIE::rehydrate_from(u32 offset, Optional<u32> parent_offset)
|
||||||
m_tag = EntryTag::None;
|
m_tag = EntryTag::None;
|
||||||
} else {
|
} else {
|
||||||
auto abbreviation_info = m_compilation_unit.abbreviations_map().get(m_abbreviation_code);
|
auto abbreviation_info = m_compilation_unit.abbreviations_map().get(m_abbreviation_code);
|
||||||
VERIFY(abbreviation_info.has_value());
|
VERIFY(abbreviation_info);
|
||||||
|
|
||||||
m_tag = abbreviation_info.value().tag;
|
m_tag = abbreviation_info->tag;
|
||||||
m_has_children = abbreviation_info.value().has_children;
|
m_has_children = abbreviation_info->has_children;
|
||||||
|
|
||||||
// We iterate the attributes data only to calculate this DIE's size
|
// We iterate the attributes data only to calculate this DIE's size
|
||||||
for (auto& attribute_spec : abbreviation_info.value().attribute_specifications) {
|
for (auto& attribute_spec : abbreviation_info->attribute_specifications) {
|
||||||
m_compilation_unit.dwarf_info().get_attribute_value(attribute_spec.form, attribute_spec.value, stream, &m_compilation_unit);
|
m_compilation_unit.dwarf_info().get_attribute_value(attribute_spec.form, attribute_spec.value, stream, &m_compilation_unit);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -52,9 +52,9 @@ Optional<AttributeValue> DIE::get_attribute(Attribute const& attribute) const
|
||||||
stream.discard_or_error(m_data_offset);
|
stream.discard_or_error(m_data_offset);
|
||||||
|
|
||||||
auto abbreviation_info = m_compilation_unit.abbreviations_map().get(m_abbreviation_code);
|
auto abbreviation_info = m_compilation_unit.abbreviations_map().get(m_abbreviation_code);
|
||||||
VERIFY(abbreviation_info.has_value());
|
VERIFY(abbreviation_info);
|
||||||
|
|
||||||
for (const auto& attribute_spec : abbreviation_info.value().attribute_specifications) {
|
for (const auto& attribute_spec : abbreviation_info->attribute_specifications) {
|
||||||
auto value = m_compilation_unit.dwarf_info().get_attribute_value(attribute_spec.form, attribute_spec.value, stream, &m_compilation_unit);
|
auto value = m_compilation_unit.dwarf_info().get_attribute_value(attribute_spec.form, attribute_spec.value, stream, &m_compilation_unit);
|
||||||
if (attribute_spec.attribute == attribute) {
|
if (attribute_spec.attribute == attribute) {
|
||||||
return value;
|
return value;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue