Optimize symbol map in debug mode a bit more.

Avoid UpdateActiveSymbols().
This commit is contained in:
Unknown W. Brackets 2014-02-14 21:49:20 -08:00
parent d0d4e665d1
commit 26b4335637
3 changed files with 14 additions and 9 deletions

View file

@ -15,6 +15,12 @@
// Official git repository and contact information can be found at // Official git repository and contact information can be found at
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/. // https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
// These functions tends to be slow in debug mode.
// Comment this out if debugging the symbol map itself.
#if defined(_MSC_VER) && defined(_DEBUG)
#pragma optimize("gty", on)
#endif
#ifdef _WIN32 #ifdef _WIN32
#include "Common/CommonWindows.h" #include "Common/CommonWindows.h"
#include <WindowsX.h> #include <WindowsX.h>
@ -728,7 +734,7 @@ void SymbolMap::AddLabel(const char* name, u32 address, int moduleIndex) {
} }
} }
void SymbolMap::SetLabelName(const char* name, u32 address, bool updateImmediately) { void SymbolMap::SetLabelName(const char* name, u32 address) {
lock_guard guard(lock_); lock_guard guard(lock_);
auto labelInfo = activeLabels.find(address); auto labelInfo = activeLabels.find(address);
if (labelInfo == activeLabels.end()) { if (labelInfo == activeLabels.end()) {
@ -740,10 +746,11 @@ void SymbolMap::SetLabelName(const char* name, u32 address, bool updateImmediate
strcpy(label->second.name,name); strcpy(label->second.name,name);
label->second.name[127] = 0; label->second.name[127] = 0;
// Allow the caller to skip this as it causes extreme startup slowdown // Refresh the active item if it exists.
// when this gets called for every function identified by the function replacement code. auto active = activeLabels.find(address);
if (updateImmediately) { if (active != activeLabels.end() && active->second.module == label->second.module) {
UpdateActiveSymbols(); activeLabels.erase(active);
activeLabels.insert(std::make_pair(address, label->second));
} }
} }
} }

View file

@ -98,7 +98,7 @@ public:
void AddLabel(const char* name, u32 address, int moduleIndex = -1); void AddLabel(const char* name, u32 address, int moduleIndex = -1);
std::string GetLabelString(u32 address) const; std::string GetLabelString(u32 address) const;
void SetLabelName(const char* name, u32 address, bool updateImmediately = true); void SetLabelName(const char* name, u32 address);
bool GetLabelValue(const char* name, u32& dest); bool GetLabelValue(const char* name, u32& dest);
void AddData(u32 address, u32 size, DataType type, int moduleIndex = -1); void AddData(u32 address, u32 size, DataType type, int moduleIndex = -1);

View file

@ -641,13 +641,11 @@ skip:
char defaultLabel[256]; char defaultLabel[256];
// If it was renamed, keep it. Only change the name if it's still the default. // If it was renamed, keep it. Only change the name if it's still the default.
if (existingLabel.empty() || !strcmp(existingLabel.c_str(), DefaultFunctionName(defaultLabel, f.start))) { if (existingLabel.empty() || !strcmp(existingLabel.c_str(), DefaultFunctionName(defaultLabel, f.start))) {
symbolMap.SetLabelName(mf->name, f.start, false); symbolMap.SetLabelName(mf->name, f.start);
} }
} }
} }
} }
// Used to be called in SetLabelName, let's call it only once instead.
symbolMap.UpdateActiveSymbols();
} }
void LoadHashMap(std::string filename) { void LoadHashMap(std::string filename) {