diff options
author | Andreas Kling <kling@serenityos.org> | 2021-09-04 17:38:32 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-09-04 20:30:56 +0200 |
commit | e40e91b9df4e55173b5e3d8aaad1e3a005f35151 (patch) | |
tree | b18c647131113e5dd9a206a6751f8c24e1037a4a /Userland/Libraries/LibDebug | |
parent | 500067d3a62ac87f78adaaa0bd6f290a915c5fe5 (diff) | |
download | serenity-e40e91b9df4e55173b5e3d8aaad1e3a005f35151.zip |
LibDebug: Use HashMap::ensure() in DebugInfo::prepare_lines()
Diffstat (limited to 'Userland/Libraries/LibDebug')
-rw-r--r-- | Userland/Libraries/LibDebug/DebugInfo.cpp | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/Userland/Libraries/LibDebug/DebugInfo.cpp b/Userland/Libraries/LibDebug/DebugInfo.cpp index fc54a5d82e..4c2f9122b0 100644 --- a/Userland/Libraries/LibDebug/DebugInfo.cpp +++ b/Userland/Libraries/LibDebug/DebugInfo.cpp @@ -99,14 +99,10 @@ void DebugInfo::prepare_lines() 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()) { - memoized_full_paths.set(line_info.file, compute_full_path(line_info.file)); - it = memoized_full_paths.find(line_info.file); - } - if (!it->value.has_value()) + auto maybe_full_path = memoized_full_paths.ensure(line_info.file, [&] { return compute_full_path(line_info.file); }); + if (!maybe_full_path.has_value()) continue; - m_sorted_lines.unchecked_append({ line_info.address, it->value.value(), line_info.line }); + m_sorted_lines.unchecked_append({ line_info.address, maybe_full_path.release_value(), line_info.line }); } quick_sort(m_sorted_lines, [](auto& a, auto& b) { |