mirror of https://github.com/WerWolv/ImHex.git
fix: Drastically improve pattern highlighting performance
This commit is contained in:
parent
ef5fbba56b
commit
2d982e2088
|
@ -1 +1 @@
|
||||||
Subproject commit f33fc83cedb1e74bd4f583c90ff77b397e7b5c03
|
Subproject commit 661ecab439922a923bb6ce1c01546044983d3bac
|
|
@ -230,36 +230,33 @@ namespace hex::plugin::builtin {
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
ImHexApi::HexEditor::addBackgroundHighlightingProvider([](u64 address, const u8 *data, size_t size) -> std::optional<color_t> {
|
ImHexApi::HexEditor::addBackgroundHighlightingProvider([this](u64 address, const u8 *data, size_t size) -> std::optional<color_t> {
|
||||||
hex::unused(data, size);
|
hex::unused(data, size);
|
||||||
|
|
||||||
const auto &patterns = ImHexApi::Provider::get()->getPatternLanguageRuntime().getPatterns();
|
if (this->m_runningEvaluators != 0)
|
||||||
for (const auto &pattern : patterns) {
|
return std::nullopt;
|
||||||
auto child = pattern->getPattern(address);
|
|
||||||
if (child != nullptr) {
|
|
||||||
return child->getColor();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
const auto pattern = ImHexApi::Provider::get()->getPatternLanguageRuntime().getPattern(address, size);
|
||||||
|
if (pattern != nullptr)
|
||||||
|
return pattern->getColor();
|
||||||
|
else
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
});
|
});
|
||||||
|
|
||||||
ImHexApi::HexEditor::addTooltipProvider([this](u64 address, const u8 *data, size_t size) {
|
ImHexApi::HexEditor::addTooltipProvider([this](u64 address, const u8 *data, size_t size) {
|
||||||
hex::unused(data, size);
|
hex::unused(data, size);
|
||||||
|
|
||||||
auto &patterns = ImHexApi::Provider::get()->getPatternLanguageRuntime().getPatterns();
|
auto pattern = ImHexApi::Provider::get()->getPatternLanguageRuntime().getPattern(address);
|
||||||
for (auto &pattern : patterns) {
|
if (pattern != nullptr) {
|
||||||
auto child = pattern->getPattern(address);
|
|
||||||
if (child != nullptr) {
|
|
||||||
ImGui::BeginTooltip();
|
ImGui::BeginTooltip();
|
||||||
|
|
||||||
if (ImGui::BeginTable("##tooltips", 1, ImGuiTableFlags_NoHostExtendX | ImGuiTableFlags_RowBg | ImGuiTableFlags_NoClip)) {
|
if (ImGui::BeginTable("##tooltips", 1, ImGuiTableFlags_NoHostExtendX | ImGuiTableFlags_RowBg | ImGuiTableFlags_NoClip)) {
|
||||||
ImGui::TableNextRow();
|
ImGui::TableNextRow();
|
||||||
ImGui::TableNextColumn();
|
ImGui::TableNextColumn();
|
||||||
|
|
||||||
this->drawPatternTooltip(child);
|
this->drawPatternTooltip(pattern);
|
||||||
|
|
||||||
auto tooltipColor = (child->getColor() & 0x00FF'FFFF) | 0x7000'0000;
|
auto tooltipColor = (pattern->getColor() & 0x00FF'FFFF) | 0x7000'0000;
|
||||||
ImGui::PushStyleColor(ImGuiCol_TableRowBg, tooltipColor);
|
ImGui::PushStyleColor(ImGuiCol_TableRowBg, tooltipColor);
|
||||||
ImGui::PushStyleColor(ImGuiCol_TableRowBgAlt, tooltipColor);
|
ImGui::PushStyleColor(ImGuiCol_TableRowBgAlt, tooltipColor);
|
||||||
ImGui::EndTable();
|
ImGui::EndTable();
|
||||||
|
@ -267,7 +264,6 @@ namespace hex::plugin::builtin {
|
||||||
}
|
}
|
||||||
ImGui::EndTooltip();
|
ImGui::EndTooltip();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -787,6 +783,8 @@ namespace hex::plugin::builtin {
|
||||||
this->m_lastEvaluationError = runtime.getError();
|
this->m_lastEvaluationError = runtime.getError();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
runtime.flattenPatterns();
|
||||||
|
|
||||||
this->m_lastEvaluationLog = runtime.getConsoleLog();
|
this->m_lastEvaluationLog = runtime.getConsoleLog();
|
||||||
this->m_lastEvaluationOutVars = runtime.getOutVariables();
|
this->m_lastEvaluationOutVars = runtime.getOutVariables();
|
||||||
this->m_runningEvaluators--;
|
this->m_runningEvaluators--;
|
||||||
|
|
Loading…
Reference in New Issue