mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
Use a lookup for function replacements.
Ought to be a tiny bit quicker.
This commit is contained in:
parent
d060a06fa6
commit
5525c0a485
1 changed files with 11 additions and 7 deletions
|
@ -624,12 +624,20 @@ static const ReplacementTableEntry entries[] = {
|
|||
|
||||
|
||||
static std::map<u32, u32> replacedInstructions;
|
||||
static std::map<std::string, int> replacementNameLookup;
|
||||
|
||||
void Replacement_Init() {
|
||||
for (int i = 0; i < (int)ARRAY_SIZE(entries); i++) {
|
||||
const auto entry = &entries[i];
|
||||
if (!entry->name || (entry->flags & REPFLAG_DISABLED) != 0)
|
||||
continue;
|
||||
replacementNameLookup[entry->name] = i;
|
||||
}
|
||||
}
|
||||
|
||||
void Replacement_Shutdown() {
|
||||
replacedInstructions.clear();
|
||||
replacementNameLookup.clear();
|
||||
}
|
||||
|
||||
// TODO: Do something on load state?
|
||||
|
@ -644,13 +652,9 @@ int GetReplacementFuncIndex(u64 hash, int funcSize) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
// TODO: Build a lookup and keep it around
|
||||
for (size_t i = 0; i < ARRAY_SIZE(entries); i++) {
|
||||
if (!entries[i].name || (entries[i].flags & REPFLAG_DISABLED) != 0)
|
||||
continue;
|
||||
if (!strcmp(name, entries[i].name)) {
|
||||
return (int)i;
|
||||
}
|
||||
auto index = replacementNameLookup.find(name);
|
||||
if (index != replacementNameLookup.end()) {
|
||||
return index->second;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue