diff options
author | Andreas Kling <kling@serenityos.org> | 2021-05-15 09:54:01 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-05-15 11:01:05 +0200 |
commit | 08c55b7606469bc9f1e8f9623a1bddc4de730864 (patch) | |
tree | 4aa3a3f3ae03d72a4fd0fb2416386787242df594 /Userland/Libraries | |
parent | a4099fc7564d7a4030f16fcacd5cfd542a593e56 (diff) | |
download | serenity-08c55b7606469bc9f1e8f9623a1bddc4de730864.zip |
LibDebug: Avoid unnecessary String allocation in append_to_line_info()
This code path is very hot, and since we're seeing a lot of the same
strings repeatedly (and they're heading into a FlyString for storage)
let's construct those using FlyString(StringView) to avoid temporary
String objects.
Diffstat (limited to 'Userland/Libraries')
-rw-r--r-- | Userland/Libraries/LibDebug/Dwarf/LineProgram.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/Userland/Libraries/LibDebug/Dwarf/LineProgram.cpp b/Userland/Libraries/LibDebug/Dwarf/LineProgram.cpp index 238d071fe4..b0d7d24b17 100644 --- a/Userland/Libraries/LibDebug/Dwarf/LineProgram.cpp +++ b/Userland/Libraries/LibDebug/Dwarf/LineProgram.cpp @@ -130,14 +130,14 @@ void LineProgram::append_to_line_info() if (m_file_index >= m_source_files.size()) return; - String directory = m_source_directories[m_source_files[m_file_index].directory_index]; + auto const& directory = m_source_directories[m_source_files[m_file_index].directory_index]; StringBuilder full_path(directory.length() + m_source_files[m_file_index].name.length() + 1); full_path.append(directory); full_path.append('/'); full_path.append(m_source_files[m_file_index].name); - m_lines.append({ m_address, full_path.to_string(), m_line }); + m_lines.append({ m_address, FlyString { full_path.string_view() }, m_line }); } void LineProgram::reset_registers() |