diff options
author | Andreas Kling <kling@serenityos.org> | 2021-05-23 23:17:26 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-05-23 23:17:26 +0200 |
commit | 4f4cde237983cfe9d9d2ebc186cb283b7262ed4a (patch) | |
tree | b0035df98433704377ddd66223da1043ddb45cbd /Userland/Libraries/LibDebug | |
parent | 0bf3df28b9479583d045588341221c4bd67edc0b (diff) | |
download | serenity-4f4cde237983cfe9d9d2ebc186cb283b7262ed4a.zip |
LibDebug: Pre-allocate capacity for the LineProgram::LineInfo vector
This shaves another ~15% off of "bt 12" on my machine :^)
Diffstat (limited to 'Userland/Libraries/LibDebug')
-rw-r--r-- | Userland/Libraries/LibDebug/DebugInfo.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/Userland/Libraries/LibDebug/DebugInfo.cpp b/Userland/Libraries/LibDebug/DebugInfo.cpp index 4af2ea5c09..8a943a10e0 100644 --- a/Userland/Libraries/LibDebug/DebugInfo.cpp +++ b/Userland/Libraries/LibDebug/DebugInfo.cpp @@ -103,6 +103,8 @@ void DebugInfo::prepare_lines() return file_path; }; + m_sorted_lines.ensure_capacity(all_lines.size()); + for (auto const& line_info : all_lines) { auto it = memoized_full_paths.find(line_info.file); if (it == memoized_full_paths.end()) { @@ -111,8 +113,9 @@ void DebugInfo::prepare_lines() } if (!it->value.has_value()) continue; - m_sorted_lines.append({ line_info.address, it->value.value(), line_info.line }); + m_sorted_lines.unchecked_append({ line_info.address, it->value.value(), line_info.line }); } + quick_sort(m_sorted_lines, [](auto& a, auto& b) { return a.address < b.address; }); |