mirror of
https://github.com/hrydgard/ppsspp.git
synced 2024-11-24 22:10:01 +00:00
Small optimization: avoid fallback if possible.
Speeds up symbol map loading a little bit (when inserting new items.)
This commit is contained in:
parent
1d8375924a
commit
04776c8125
@ -494,13 +494,15 @@ void SymbolMap::AddFunction(const char* name, u32 address, u32 size, int moduleI
|
|||||||
|
|
||||||
if (moduleIndex == -1) {
|
if (moduleIndex == -1) {
|
||||||
moduleIndex = GetModuleIndex(address);
|
moduleIndex = GetModuleIndex(address);
|
||||||
|
} else if (moduleIndex == 0) {
|
||||||
|
sawUnknownModule = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Is there an existing one?
|
// Is there an existing one?
|
||||||
u32 relAddress = GetModuleRelativeAddr(address, moduleIndex);
|
u32 relAddress = GetModuleRelativeAddr(address, moduleIndex);
|
||||||
auto symbolKey = std::make_pair(moduleIndex, relAddress);
|
auto symbolKey = std::make_pair(moduleIndex, relAddress);
|
||||||
auto existing = functions.find(symbolKey);
|
auto existing = functions.find(symbolKey);
|
||||||
if (existing == functions.end()) {
|
if (sawUnknownModule && existing == functions.end()) {
|
||||||
// Fall back: maybe it's got moduleIndex = 0.
|
// Fall back: maybe it's got moduleIndex = 0.
|
||||||
existing = functions.find(std::make_pair(0, address));
|
existing = functions.find(std::make_pair(0, address));
|
||||||
}
|
}
|
||||||
@ -692,13 +694,15 @@ void SymbolMap::AddLabel(const char* name, u32 address, int moduleIndex) {
|
|||||||
|
|
||||||
if (moduleIndex == -1) {
|
if (moduleIndex == -1) {
|
||||||
moduleIndex = GetModuleIndex(address);
|
moduleIndex = GetModuleIndex(address);
|
||||||
|
} else if (moduleIndex == 0) {
|
||||||
|
sawUnknownModule = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Is there an existing one?
|
// Is there an existing one?
|
||||||
u32 relAddress = GetModuleRelativeAddr(address, moduleIndex);
|
u32 relAddress = GetModuleRelativeAddr(address, moduleIndex);
|
||||||
auto symbolKey = std::make_pair(moduleIndex, relAddress);
|
auto symbolKey = std::make_pair(moduleIndex, relAddress);
|
||||||
auto existing = labels.find(symbolKey);
|
auto existing = labels.find(symbolKey);
|
||||||
if (existing == labels.end()) {
|
if (sawUnknownModule && existing == labels.end()) {
|
||||||
// Fall back: maybe it's got moduleIndex = 0.
|
// Fall back: maybe it's got moduleIndex = 0.
|
||||||
existing = labels.find(std::make_pair(0, address));
|
existing = labels.find(std::make_pair(0, address));
|
||||||
}
|
}
|
||||||
@ -799,13 +803,15 @@ void SymbolMap::AddData(u32 address, u32 size, DataType type, int moduleIndex) {
|
|||||||
|
|
||||||
if (moduleIndex == -1) {
|
if (moduleIndex == -1) {
|
||||||
moduleIndex = GetModuleIndex(address);
|
moduleIndex = GetModuleIndex(address);
|
||||||
|
} else if (moduleIndex == 0) {
|
||||||
|
sawUnknownModule = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Is there an existing one?
|
// Is there an existing one?
|
||||||
u32 relAddress = GetModuleRelativeAddr(address, moduleIndex);
|
u32 relAddress = GetModuleRelativeAddr(address, moduleIndex);
|
||||||
auto symbolKey = std::make_pair(moduleIndex, relAddress);
|
auto symbolKey = std::make_pair(moduleIndex, relAddress);
|
||||||
auto existing = data.find(symbolKey);
|
auto existing = data.find(symbolKey);
|
||||||
if (existing == data.end()) {
|
if (sawUnknownModule && existing == data.end()) {
|
||||||
// Fall back: maybe it's got moduleIndex = 0.
|
// Fall back: maybe it's got moduleIndex = 0.
|
||||||
existing = data.find(std::make_pair(0, address));
|
existing = data.find(std::make_pair(0, address));
|
||||||
}
|
}
|
||||||
|
@ -63,7 +63,7 @@ typedef struct HWND__ *HWND;
|
|||||||
|
|
||||||
class SymbolMap {
|
class SymbolMap {
|
||||||
public:
|
public:
|
||||||
SymbolMap() {}
|
SymbolMap() : sawUnknownModule(false) {}
|
||||||
void Clear();
|
void Clear();
|
||||||
void SortSymbols();
|
void SortSymbols();
|
||||||
|
|
||||||
@ -160,6 +160,7 @@ private:
|
|||||||
std::vector<ModuleEntry> modules;
|
std::vector<ModuleEntry> modules;
|
||||||
|
|
||||||
mutable recursive_mutex lock_;
|
mutable recursive_mutex lock_;
|
||||||
|
bool sawUnknownModule;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern SymbolMap symbolMap;
|
extern SymbolMap symbolMap;
|
||||||
|
Loading…
Reference in New Issue
Block a user