Skip to content

Commit 6b3b402

Browse files
committed
evaluator: Remove threaded highlighting generation again
1 parent c5c7005 commit 6b3b402

1 file changed

Lines changed: 21 additions & 19 deletions

File tree

lib/source/pl/pattern_language.cpp

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -508,37 +508,39 @@ namespace pl {
508508
}
509509

510510
void PatternLanguage::flattenPatterns() {
511-
m_flattenThread = std::thread([this] {
512-
for (const auto &[section, patterns] : this->m_patterns) {
511+
for (const auto &[section, patterns] : this->m_patterns) {
512+
if (this->m_aborted)
513+
return;
514+
515+
auto &sectionTree = this->m_flattenedPatterns[section];
516+
for (const auto &pattern : patterns) {
513517
if (this->m_aborted)
514518
return;
515519

516-
auto &sectionTree = this->m_flattenedPatterns[section];
517-
for (const auto &pattern : patterns) {
520+
if (auto staticArray = dynamic_cast<ptrn::PatternArrayStatic*>(pattern.get()); staticArray != nullptr) {
521+
if (staticArray->getEntryCount() > 0 && staticArray->getEntry(0)->getChildren().empty()) {
522+
const auto address = staticArray->getOffset();
523+
const auto size = staticArray->getSize();
524+
sectionTree.insert({ address, address + size - 1 }, staticArray);
525+
continue;
526+
}
527+
}
528+
529+
auto children = pattern->getChildren();
530+
for (const auto &[address, child] : children) {
518531
if (this->m_aborted)
519532
return;
520533

521-
auto children = pattern->getChildren();
522-
for (const auto &[address, child] : children) {
523-
if (this->m_aborted)
524-
return;
525-
526-
if (child->getSize() == 0)
527-
continue;
534+
if (child->getSize() == 0)
535+
continue;
528536

529-
sectionTree.insert({ address, address + child->getSize() - 1 }, child);
530-
}
537+
sectionTree.insert({ address, address + child->getSize() - 1 }, child);
531538
}
532539
}
533-
534-
this->m_flattenedPatternsValid = true;
535-
});
540+
}
536541
}
537542

538543
std::vector<ptrn::Pattern *> PatternLanguage::getPatternsAtAddress(u64 address, u64 section) const {
539-
if (!this->m_flattenedPatternsValid)
540-
return { };
541-
542544
if (this->m_flattenedPatterns.empty() || !this->m_flattenedPatterns.contains(section))
543545
return { };
544546

0 commit comments

Comments
 (0)