Fix performance of dlist viewer (#3961)

This commit is contained in:
Archez 2024-02-21 00:20:25 -05:00 committed by GitHub
parent cd5d2589f7
commit cd25f1d3c1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -9,7 +9,6 @@
#include <bit> #include <bit>
#include <map> #include <map>
#include <string> #include <string>
#include <regex>
#include <libultraship/libultraship.h> #include <libultraship/libultraship.h>
#include "dlViewer.h" #include "dlViewer.h"
@ -68,14 +67,12 @@ std::map<int, std::string> cmdMap = {
void PerformDisplayListSearch() { void PerformDisplayListSearch() {
auto result = LUS::Context::GetInstance()->GetResourceManager()->GetArchiveManager()->ListFiles("*" + std::string(searchString) + "*DL*"); auto result = LUS::Context::GetInstance()->GetResourceManager()->GetArchiveManager()->ListFiles("*" + std::string(searchString) + "*DL*");
std::regex dlSearch(".*((DL)|(DL_.*))$");
displayListSearchResults.clear(); displayListSearchResults.clear();
// Filter the file results even further as StormLib can only use wildcard searching // Filter the file results even further as StormLib can only use wildcard searching
for (size_t i = 0; i < result->size(); i++) { for (size_t i = 0; i < result->size(); i++) {
std::string val = result->at(i); std::string val = result->at(i);
if (std::regex_search(val.c_str(), dlSearch)) { if (val.ends_with("DL") || val.find("DL_") != std::string::npos) {
displayListSearchResults.push_back(val); displayListSearchResults.push_back(val);
} }
} }
@ -99,8 +96,6 @@ void DLViewerWindow::DrawElement() {
return; return;
} }
ImGui::Text("%d", searchDebounceFrames);
// Debounce the search field as listing otr files is expensive // Debounce the search field as listing otr files is expensive
if (ImGui::InputText("Search Display Lists", searchString, ARRAY_COUNT(searchString))) { if (ImGui::InputText("Search Display Lists", searchString, ARRAY_COUNT(searchString))) {
doSearch = true; doSearch = true;