mirror of
https://github.com/ran-j/PS2Recomp.git
synced 2026-09-27 17:11:31 -04:00
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:
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user