From 5c151c11accc1879c137fefc7fa6206d697248e8 Mon Sep 17 00:00:00 2001 From: Sepalani Date: Sun, 24 Nov 2024 12:26:21 +0400 Subject: [PATCH] PPCSymbolDB: Use ranges in SaveSymbolMap --- Source/Core/Core/PowerPC/PPCSymbolDB.cpp | 38 +++++++++++------------- 1 file changed, 17 insertions(+), 21 deletions(-) diff --git a/Source/Core/Core/PowerPC/PPCSymbolDB.cpp b/Source/Core/Core/PowerPC/PPCSymbolDB.cpp index 95102fa179..77decee7ba 100644 --- a/Source/Core/Core/PowerPC/PPCSymbolDB.cpp +++ b/Source/Core/Core/PowerPC/PPCSymbolDB.cpp @@ -6,11 +6,11 @@ #include #include #include +#include #include #include #include #include -#include #include @@ -466,42 +466,38 @@ bool PPCSymbolDB::SaveSymbolMap(const std::string& filename) const if (!f) return false; - std::vector function_symbols; - std::vector data_symbols; - - for (const auto& function : m_functions) - { - const Common::Symbol& symbol = function.second; - if (symbol.type == Common::Symbol::Type::Function) - function_symbols.push_back(&symbol); - else - data_symbols.push_back(&symbol); - } - // Write .text section + auto function_symbols = + m_functions | + std::views::filter([](auto f) { return f.second.type == Common::Symbol::Type::Function; }) | + std::views::transform([](auto f) { return f.second; }); f.WriteString(".text section layout\n"); for (const auto& symbol : function_symbols) { // Write symbol address, size, virtual address, alignment, name - std::string line = fmt::format("{0:08x} {1:06x} {2:08x} {3} {4}", symbol->address, symbol->size, - symbol->address, 0, symbol->name); + std::string line = fmt::format("{:08x} {:06x} {:08x} {} {}", symbol.address, symbol.size, + symbol.address, 0, symbol.name); // Also write the object name if it exists - if (!symbol->object_name.empty()) - line += fmt::format(" \t{0}", symbol->object_name); + if (!symbol.object_name.empty()) + line += fmt::format(" \t{0}", symbol.object_name); line += "\n"; f.WriteString(line); } // Write .data section + auto data_symbols = + m_functions | + std::views::filter([](auto f) { return f.second.type == Common::Symbol::Type::Data; }) | + std::views::transform([](auto f) { return f.second; }); f.WriteString("\n.data section layout\n"); for (const auto& symbol : data_symbols) { // Write symbol address, size, virtual address, alignment, name - std::string line = fmt::format("{0:08x} {1:06x} {2:08x} {3} {4}", symbol->address, symbol->size, - symbol->address, 0, symbol->name); + std::string line = fmt::format("{:08x} {:06x} {:08x} {} {}", symbol.address, symbol.size, + symbol.address, 0, symbol.name); // Also write the object name if it exists - if (!symbol->object_name.empty()) - line += fmt::format(" \t{0}", symbol->object_name); + if (!symbol.object_name.empty()) + line += fmt::format(" \t{0}", symbol.object_name); line += "\n"; f.WriteString(line); }