Cache symbols and use a clipper to speed up the symbol list.

This commit is contained in:
Henrik Rydgård 2024-11-07 11:06:10 +01:00
parent 99eb0bbd64
commit dd26bcf1af
3 changed files with 17 additions and 6 deletions

View File

@ -21,7 +21,6 @@
#include <set> #include <set>
#include <map> #include <map>
#include <string> #include <string>
#include <functional>
#include <mutex> #include <mutex>
#include "Common/CommonTypes.h" #include "Common/CommonTypes.h"
@ -163,6 +162,7 @@ private:
// This is indexed by the end address of the module. // This is indexed by the end address of the module.
std::map<u32, const ModuleEntry> activeModuleEnds; std::map<u32, const ModuleEntry> activeModuleEnds;
// Module ID, index
typedef std::pair<int, u32> SymbolKey; typedef std::pair<int, u32> SymbolKey;
// These are indexed by the module id and relative address in the module. // These are indexed by the module id and relative address in the module.

View File

@ -196,13 +196,21 @@ void ImDisasmWindow::Draw(MIPSDebugInterface *mipsDebug, bool *open, CoreState c
ImGui::TableSetColumnIndex(0); ImGui::TableSetColumnIndex(0);
ImVec2 sz = ImGui::GetContentRegionAvail(); ImVec2 sz = ImGui::GetContentRegionAvail();
if (ImGui::BeginListBox("##symbols", ImVec2(150.0, sz.y - ImGui::GetTextLineHeightWithSpacing() * 2))) { if (ImGui::BeginListBox("##symbols", ImVec2(150.0, sz.y - ImGui::GetTextLineHeightWithSpacing() * 2))) {
std::vector<SymbolEntry> syms = g_symbolMap->GetAllSymbols(SymbolType::ST_FUNCTION); if (symCache_.empty()) {
for (auto &sym : syms) { symCache_ = g_symbolMap->GetAllSymbols(SymbolType::ST_FUNCTION);
if (ImGui::Selectable(sym.name.c_str(), false)) { }
disasmView_.setCurAddress(sym.address); ImGuiListClipper clipper;
clipper.Begin((int)symCache_.size(), -1);
while (clipper.Step()) {
for (int i = clipper.DisplayStart; i < clipper.DisplayEnd; i++) {
if (ImGui::Selectable(symCache_[i].name.c_str(), false)) {
disasmView_.setCurAddress(symCache_[i].address);
disasmView_.scrollAddressIntoView(); disasmView_.scrollAddressIntoView();
} }
} }
}
clipper.End();
ImGui::EndListBox(); ImGui::EndListBox();
} }

View File

@ -37,6 +37,9 @@ private:
u32 gotoAddr_ = 0x1000; u32 gotoAddr_ = 0x1000;
// Symbol cache
std::vector<SymbolEntry> symCache_;
ImDisasmView disasmView_; ImDisasmView disasmView_;
}; };