1
0
mirror of synced 2024-11-14 11:07:43 +01:00

impr: Better find view result filter speeds

This commit is contained in:
WerWolv 2023-03-17 11:32:08 +01:00
parent f10fb56042
commit 880568cc60
2 changed files with 15 additions and 5 deletions

View File

@ -96,7 +96,7 @@ namespace hex::plugin::builtin {
std::map<prv::Provider*, OccurrenceTree> m_occurrenceTree;
std::map<prv::Provider*, std::string> m_currFilter;
TaskHolder m_searchTask;
TaskHolder m_searchTask, m_filterTask;
bool m_settingsValid = false;
private:

View File

@ -786,12 +786,22 @@ namespace hex::plugin::builtin {
auto &currOccurrences = this->m_sortedOccurrences[provider];
ImGui::PushItemWidth(ImGui::GetContentRegionAvail().x);
auto prevFilterLength = this->m_currFilter[provider].length();
if (ImGui::InputTextWithHint("##filter", "hex.builtin.common.filter"_lang, this->m_currFilter[provider])) {
this->m_sortedOccurrences[provider] = this->m_foundOccurrences[provider];
if (prevFilterLength > this->m_currFilter[provider].length())
this->m_sortedOccurrences[provider] = this->m_foundOccurrences[provider];
currOccurrences.erase(std::remove_if(currOccurrences.begin(), currOccurrences.end(), [this, provider](const auto &region) {
return !hex::containsIgnoreCase(this->decodeValue(provider, region), this->m_currFilter[provider]);
}), currOccurrences.end());
if (this->m_filterTask.isRunning())
this->m_filterTask.interrupt();
if (!this->m_currFilter[provider].empty()) {
this->m_filterTask = TaskManager::createTask("Filtering", 0, [this, provider, &currOccurrences](Task &task) {
currOccurrences.erase(std::remove_if(currOccurrences.begin(), currOccurrences.end(), [this, provider, &task](const auto &region) {
task.update();
return !hex::containsIgnoreCase(this->decodeValue(provider, region), this->m_currFilter[provider]);
}), currOccurrences.end());
});
}
}
ImGui::PopItemWidth();