Merge pull request #29 from playmer/playmer/fix_lookup

Convert CodeGenerator::m_symbols to unordered_map to fix O(n) lookups
This commit is contained in:
Joshua T. Fisher
2026-01-28 19:20:46 -08:00
committed by GitHub
parent 9174f52511
commit 91678d1977
2 changed files with 7 additions and 8 deletions
@@ -39,7 +39,7 @@ namespace ps2recomp
const std::vector<Instruction> &instructions);
public:
std::vector<Symbol> m_symbols;
std::unordered_map<uint32_t, Symbol> m_symbols;
std::unordered_map<uint32_t, std::string> m_renamedFunctions;
BootstrapInfo m_bootstrapInfo;
+6 -7
View File
@@ -28,8 +28,10 @@ namespace ps2recomp
namespace ps2recomp
{
CodeGenerator::CodeGenerator(const std::vector<Symbol> &symbols)
: m_symbols(symbols)
{
for (auto& symbol : symbols) {
m_symbols.emplace(symbol.address, symbol);
}
}
void CodeGenerator::setRenamedFunctions(const std::unordered_map<uint32_t, std::string> &renames)
@@ -2573,12 +2575,9 @@ namespace ps2recomp
Symbol *CodeGenerator::findSymbolByAddress(uint32_t address)
{
for (auto &symbol : m_symbols)
{
if (symbol.address == address)
{
return &symbol;
}
auto it = m_symbols.find(address);
if (it != m_symbols.end()) {
return &it->second;
}
return nullptr;