PPCSymbolDB: Optimise symbol lookups
This commit is contained in:
parent
8cd8e9d905
commit
cc40931d64
|
@ -79,19 +79,20 @@ void PPCSymbolDB::AddKnownSymbol(u32 startAddr, u32 size, const std::string& nam
|
||||||
|
|
||||||
Symbol* PPCSymbolDB::GetSymbolFromAddr(u32 addr)
|
Symbol* PPCSymbolDB::GetSymbolFromAddr(u32 addr)
|
||||||
{
|
{
|
||||||
XFuncMap::iterator it = functions.find(addr);
|
XFuncMap::iterator it = functions.lower_bound(addr);
|
||||||
if (it != functions.end())
|
if (it == functions.end())
|
||||||
{
|
return nullptr;
|
||||||
|
|
||||||
|
// If the address is exactly the start address of a symbol, we're done.
|
||||||
|
if (it->second.address == addr)
|
||||||
return &it->second;
|
return &it->second;
|
||||||
}
|
|
||||||
else
|
// Otherwise, check whether the address is within the bounds of a symbol.
|
||||||
{
|
if (it != functions.begin())
|
||||||
for (auto& p : functions)
|
--it;
|
||||||
{
|
if (addr >= it->second.address && addr < it->second.address + it->second.size)
|
||||||
if (addr >= p.second.address && addr < p.second.address + p.second.size)
|
return &it->second;
|
||||||
return &p.second;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue