Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ScanForFunctions: Speed up game loading by only trying to insert the newly found functions into the symbol map. #12652

Merged
merged 1 commit into from
Feb 29, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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