1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 23:58:11 +00:00

LibDebug: Use HashMap::ensure() in DebugInfo::prepare_lines()

This commit is contained in:
Andreas Kling 2021-09-04 17:38:32 +02:00
parent 500067d3a6
commit e40e91b9df

View file

@ -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) {