diff options
author | Andreas Kling <kling@serenityos.org> | 2021-02-23 19:45:29 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-02-23 19:45:29 +0100 |
commit | 4ed85e9b9e183fc5c817129c1fbef67d3a3abaf5 (patch) | |
tree | 9e427ae33ba41b90c595d948f0d5ef94fc750221 /Userland/Libraries | |
parent | 06919d189b4216f7476620fbbb862b85d5330278 (diff) | |
download | serenity-4ed85e9b9e183fc5c817129c1fbef67d3a3abaf5.zip |
LibELF: Don't build barely-used section lookup table in ELF::Image
The name-to-section lookup table was only used in a handful of places,
and none of them were calling it nearly enough to justify building
a cache for it in the first place. So let's get rid of it and reduce
startup time by a little bit. :^)
Diffstat (limited to 'Userland/Libraries')
-rw-r--r-- | Userland/Libraries/LibELF/Image.cpp | 13 | ||||
-rw-r--r-- | Userland/Libraries/LibELF/Image.h | 5 |
2 files changed, 6 insertions, 12 deletions
diff --git a/Userland/Libraries/LibELF/Image.cpp b/Userland/Libraries/LibELF/Image.cpp index ab085de330..07233f5e0d 100644 --- a/Userland/Libraries/LibELF/Image.cpp +++ b/Userland/Libraries/LibELF/Image.cpp @@ -186,12 +186,6 @@ bool Image::parse() } } - // Then create a name-to-index map. - for (unsigned i = 0; i < section_count(); ++i) { - auto section = this->section(i); - m_sections.set(section.name(), move(i)); - } - return m_valid; } @@ -298,8 +292,11 @@ Image::RelocationSection Image::Section::relocations() const Image::Section Image::lookup_section(const String& name) const { ASSERT(m_valid); - if (auto it = m_sections.find(name); it != m_sections.end()) - return section((*it).value); + for (unsigned i = 0; i < section_count(); ++i) { + auto section = this->section(i); + if (section.name() == name) + return section; + } return section(0); } diff --git a/Userland/Libraries/LibELF/Image.h b/Userland/Libraries/LibELF/Image.h index d477e09978..361be1a5c6 100644 --- a/Userland/Libraries/LibELF/Image.h +++ b/Userland/Libraries/LibELF/Image.h @@ -26,10 +26,8 @@ #pragma once -#include <AK/ByteBuffer.h> -#include <AK/HashMap.h> -#include <AK/OwnPtr.h> #include <AK/String.h> +#include <AK/Vector.h> #include <Kernel/VirtualAddress.h> #include <LibELF/exec_elf.h> @@ -230,7 +228,6 @@ private: const u8* m_buffer { nullptr }; size_t m_size { 0 }; bool m_verbose_logging { true }; - HashMap<String, unsigned> m_sections; bool m_valid { false }; unsigned m_symbol_table_section_index { 0 }; unsigned m_string_table_section_index { 0 }; |