mirror of https://github.com/WerWolv/ImHex.git
patterns: Increased highlighting performance
This commit is contained in:
parent
e3dd5900e2
commit
ae9f4fa876
|
@ -807,15 +807,16 @@ namespace hex::pl {
|
||||||
|
|
||||||
std::optional<u32> highlightBytes(size_t offset) override{
|
std::optional<u32> highlightBytes(size_t offset) override{
|
||||||
auto entry = this->m_template->clone();
|
auto entry = this->m_template->clone();
|
||||||
|
ON_SCOPE_EXIT { delete entry; };
|
||||||
|
|
||||||
for (u64 address = this->getOffset(); address < this->getOffset() + this->getSize(); address += this->m_template->getSize()) {
|
if (offset < this->getOffset() || offset >= this->getOffset() + this->getSize())
|
||||||
entry->setOffset(address);
|
return { };
|
||||||
|
|
||||||
|
auto index = (offset - this->getOffset()) / this->m_template->getSize();
|
||||||
|
entry->setOffset(this->getOffset() + this->m_template->getSize() * index);
|
||||||
if (auto color = entry->highlightBytes(offset); color.has_value())
|
if (auto color = entry->highlightBytes(offset); color.has_value())
|
||||||
return color.value();
|
return color.value();
|
||||||
}
|
else
|
||||||
|
|
||||||
delete entry;
|
|
||||||
|
|
||||||
return { };
|
return { };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -341,9 +341,9 @@ namespace hex {
|
||||||
void ViewPatternEditor::parsePattern(char *buffer) {
|
void ViewPatternEditor::parsePattern(char *buffer) {
|
||||||
this->m_evaluatorRunning = true;
|
this->m_evaluatorRunning = true;
|
||||||
|
|
||||||
this->clearPatternData();
|
|
||||||
this->m_textEditor.SetErrorMarkers({ });
|
this->m_textEditor.SetErrorMarkers({ });
|
||||||
this->m_console.clear();
|
this->m_console.clear();
|
||||||
|
this->clearPatternData();
|
||||||
EventManager::post<EventPatternChanged>();
|
EventManager::post<EventPatternChanged>();
|
||||||
|
|
||||||
std::thread([this, buffer = std::string(buffer)] {
|
std::thread([this, buffer = std::string(buffer)] {
|
||||||
|
@ -358,9 +358,9 @@ namespace hex {
|
||||||
|
|
||||||
if (result.has_value()) {
|
if (result.has_value()) {
|
||||||
SharedData::patternData = std::move(result.value());
|
SharedData::patternData = std::move(result.value());
|
||||||
View::doLater([]{
|
//View::doLater([]{
|
||||||
EventManager::post<EventPatternChanged>();
|
EventManager::post<EventPatternChanged>();
|
||||||
});
|
//});
|
||||||
}
|
}
|
||||||
|
|
||||||
this->m_evaluatorRunning = false;
|
this->m_evaluatorRunning = false;
|
||||||
|
|
Loading…
Reference in New Issue