From 04776c81256bfe1cbd280ca1d6b3c824d6225606 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Fri, 14 Feb 2014 22:07:39 -0800 Subject: [PATCH] Small optimization: avoid fallback if possible. Speeds up symbol map loading a little bit (when inserting new items.) --- Core/Debugger/SymbolMap.cpp | 12 +++++++++--- Core/Debugger/SymbolMap.h | 3 ++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/Core/Debugger/SymbolMap.cpp b/Core/Debugger/SymbolMap.cpp index d251bb0166..0bf070d997 100644 --- a/Core/Debugger/SymbolMap.cpp +++ b/Core/Debugger/SymbolMap.cpp @@ -494,13 +494,15 @@ void SymbolMap::AddFunction(const char* name, u32 address, u32 size, int moduleI if (moduleIndex == -1) { moduleIndex = GetModuleIndex(address); + } else if (moduleIndex == 0) { + sawUnknownModule = true; } // Is there an existing one? u32 relAddress = GetModuleRelativeAddr(address, moduleIndex); auto symbolKey = std::make_pair(moduleIndex, relAddress); auto existing = functions.find(symbolKey); - if (existing == functions.end()) { + if (sawUnknownModule && existing == functions.end()) { // Fall back: maybe it's got moduleIndex = 0. 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) { moduleIndex = GetModuleIndex(address); + } else if (moduleIndex == 0) { + sawUnknownModule = true; } // Is there an existing one? u32 relAddress = GetModuleRelativeAddr(address, moduleIndex); auto symbolKey = std::make_pair(moduleIndex, relAddress); auto existing = labels.find(symbolKey); - if (existing == labels.end()) { + if (sawUnknownModule && existing == labels.end()) { // Fall back: maybe it's got moduleIndex = 0. 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) { moduleIndex = GetModuleIndex(address); + } else if (moduleIndex == 0) { + sawUnknownModule = true; } // Is there an existing one? u32 relAddress = GetModuleRelativeAddr(address, moduleIndex); auto symbolKey = std::make_pair(moduleIndex, relAddress); auto existing = data.find(symbolKey); - if (existing == data.end()) { + if (sawUnknownModule && existing == data.end()) { // Fall back: maybe it's got moduleIndex = 0. existing = data.find(std::make_pair(0, address)); } diff --git a/Core/Debugger/SymbolMap.h b/Core/Debugger/SymbolMap.h index c4cdaca020..f0716801d6 100644 --- a/Core/Debugger/SymbolMap.h +++ b/Core/Debugger/SymbolMap.h @@ -63,7 +63,7 @@ typedef struct HWND__ *HWND; class SymbolMap { public: - SymbolMap() {} + SymbolMap() : sawUnknownModule(false) {} void Clear(); void SortSymbols(); @@ -160,6 +160,7 @@ private: std::vector modules; mutable recursive_mutex lock_; + bool sawUnknownModule; }; extern SymbolMap symbolMap;