Skip to content

Commit

Permalink
Merge pull request #12652 from hrydgard/game-load-speedup
Browse files Browse the repository at this point in the history
ScanForFunctions: Speed up game loading by only trying to insert the newly found functions into the symbol map.
  • Loading branch information
hrydgard authored Feb 29, 2020
2 parents 3af63b6 + 8ddd2b6 commit 3a00e13
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions Core/MIPS/MIPSAnalyst.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1022,6 +1022,8 @@ namespace MIPSAnalyst {
bool ScanForFunctions(u32 startAddr, u32 endAddr, bool insertSymbols) {
std::lock_guard<std::recursive_mutex> guard(functions_lock);

FunctionsVector new_functions;

AnalyzedFunction currentFunction = {startAddr};

u32 furthestBranch = 0;
Expand Down Expand Up @@ -1142,7 +1144,7 @@ namespace MIPSAnalyst {
}
}

functions.push_back(currentFunction);
new_functions.push_back(currentFunction);

furthestBranch = 0;
addr += 4;
Expand All @@ -1157,17 +1159,19 @@ namespace MIPSAnalyst {

if (addr <= endAddr) {
currentFunction.end = addr + 4;
functions.push_back(currentFunction);
new_functions.push_back(currentFunction);
}

for (auto iter = functions.begin(); iter != functions.end(); iter++) {
for (auto iter = new_functions.begin(); iter != new_functions.end(); iter++) {
iter->size = iter->end - iter->start + 4;
if (insertSymbols && !iter->foundInSymbolMap) {
char temp[256];
g_symbolMap->AddFunction(DefaultFunctionName(temp, iter->start), iter->start, iter->end - iter->start + 4);
}
}

// Concatenate the new functions to the end of the old ones.
functions.insert(functions.end(), new_functions.begin(), new_functions.end());
return insertSymbols;
}

Expand Down

0 comments on commit 3a00e13

Please sign in to comment.