1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 08:47:34 +00:00

LibDebug: Use FlyString for file paths

The same file path occurs over and over in debug info, so let's store
them as FlyString to ensure we only have one of each in memory.
This commit is contained in:
Andreas Kling 2020-11-16 09:06:31 +01:00
parent 4eb3cf68b7
commit 395313039d
2 changed files with 5 additions and 5 deletions

View file

@ -43,7 +43,7 @@ public:
explicit DebugInfo(NonnullRefPtr<const ELF::Loader> elf); explicit DebugInfo(NonnullRefPtr<const ELF::Loader> elf);
struct SourcePosition { struct SourcePosition {
String file_path; FlyString file_path;
size_t line_number { 0 }; size_t line_number { 0 };
u32 address_of_first_statement { 0 }; u32 address_of_first_statement { 0 };
@ -96,7 +96,7 @@ public:
template<typename Callback> template<typename Callback>
void for_each_source_position(Callback callback) const void for_each_source_position(Callback callback) const
{ {
String previous_file = ""; FlyString previous_file = "";
size_t previous_line = 0; size_t previous_line = 0;
for (const auto& line_info : m_sorted_lines) { for (const auto& line_info : m_sorted_lines) {
if (line_info.file == previous_file && line_info.line == previous_line) if (line_info.file == previous_file && line_info.line == previous_line)

View file

@ -26,8 +26,8 @@
#pragma once #pragma once
#include <AK/FlyString.h>
#include <AK/MemoryStream.h> #include <AK/MemoryStream.h>
#include <AK/String.h>
#include <AK/Vector.h> #include <AK/Vector.h>
namespace Debug::Dwarf { namespace Debug::Dwarf {
@ -38,7 +38,7 @@ public:
struct LineInfo { struct LineInfo {
u32 address { 0 }; u32 address { 0 };
String file; FlyString file;
size_t line { 0 }; size_t line { 0 };
}; };
@ -93,7 +93,7 @@ private:
}; };
struct FileEntry { struct FileEntry {
String name; FlyString name;
size_t directory_index { 0 }; size_t directory_index { 0 };
}; };