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 <map>
#include <string>
#include <functional>
#include <mutex>
#include "Common/CommonTypes.h"
@ -163,6 +162,7 @@ private:
// This is indexed by the end address of the module.
std::map<u32, const ModuleEntry> activeModuleEnds;
// Module ID, index
typedef std::pair<int, u32> SymbolKey;
// 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);
ImVec2 sz = ImGui::GetContentRegionAvail();
if (ImGui::BeginListBox("##symbols", ImVec2(150.0, sz.y - ImGui::GetTextLineHeightWithSpacing() * 2))) {
std::vector<SymbolEntry> syms = g_symbolMap->GetAllSymbols(SymbolType::ST_FUNCTION);
for (auto &sym : syms) {
if (ImGui::Selectable(sym.name.c_str(), false)) {
disasmView_.setCurAddress(sym.address);
if (symCache_.empty()) {
symCache_ = g_symbolMap->GetAllSymbols(SymbolType::ST_FUNCTION);
}
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();
}
}
}
clipper.End();
ImGui::EndListBox();
}

View File

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