summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2020-11-16 08:49:01 +0100
committerAndreas Kling <kling@serenityos.org>2020-11-16 09:10:49 +0100
commit4eb3cf68b7bdb80df2934e9d9af49fc36060c69c (patch)
treedb27dcd144cbf81fd60a4c4f31d49b08f0dadb99
parentfe7036d8f4ce8eaa93492317dddaece4b0d92f40 (diff)
downloadserenity-4eb3cf68b7bdb80df2934e9d9af49fc36060c69c.zip
LibDebug: Avoid creating the String("serenity/") a bazillion times
We were creating and destroying this string twice for every LineInfo. That's a lot of malloc() and free() during UE startup.
-rw-r--r--Libraries/LibDebug/DebugInfo.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/Libraries/LibDebug/DebugInfo.cpp b/Libraries/LibDebug/DebugInfo.cpp
index 76461285ee..7822c30cb8 100644
--- a/Libraries/LibDebug/DebugInfo.cpp
+++ b/Libraries/LibDebug/DebugInfo.cpp
@@ -115,12 +115,14 @@ void DebugInfo::prepare_lines()
all_lines.append(program.lines());
}
+ String serenity_slash("serenity/");
+
for (auto& line_info : all_lines) {
String file_path = line_info.file;
if (file_path.contains("Toolchain/") || file_path.contains("libgcc"))
continue;
- if (file_path.contains("serenity/")) {
- auto start_index = file_path.index_of("serenity/").value() + String("serenity/").length();
+ if (file_path.contains(serenity_slash)) {
+ auto start_index = file_path.index_of(serenity_slash).value() + serenity_slash.length();
file_path = file_path.substring(start_index, file_path.length() - start_index);
}
m_sorted_lines.append({ line_info.address, file_path, line_info.line });