From 8ddd2b610439ede9397977768aa9b0c7c4102fcd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sat, 29 Feb 2020 01:00:57 +0100 Subject: [PATCH] ScanForFunctions: Drastically speed up by only trying to insert the newly found functions into the symbol map. --- Core/MIPS/MIPSAnalyst.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Core/MIPS/MIPSAnalyst.cpp b/Core/MIPS/MIPSAnalyst.cpp index 9b951848bee5..d52c2ffebddf 100644 --- a/Core/MIPS/MIPSAnalyst.cpp +++ b/Core/MIPS/MIPSAnalyst.cpp @@ -1022,6 +1022,8 @@ namespace MIPSAnalyst { bool ScanForFunctions(u32 startAddr, u32 endAddr, bool insertSymbols) { std::lock_guard guard(functions_lock); + FunctionsVector new_functions; + AnalyzedFunction currentFunction = {startAddr}; u32 furthestBranch = 0; @@ -1142,7 +1144,7 @@ namespace MIPSAnalyst { } } - functions.push_back(currentFunction); + new_functions.push_back(currentFunction); furthestBranch = 0; addr += 4; @@ -1157,10 +1159,10 @@ 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]; @@ -1168,6 +1170,8 @@ namespace MIPSAnalyst { } } + // Concatenate the new functions to the end of the old ones. + functions.insert(functions.end(), new_functions.begin(), new_functions.end()); return insertSymbols; }