1
0
mirror of synced 2024-11-28 01:20:51 +01:00

impr: Optimize time it takes to find favorites in patterns

This commit is contained in:
WerWolv 2024-07-24 19:41:12 +02:00
parent 5ca3222e5b
commit 416889f49d

View File

@ -1382,6 +1382,8 @@ namespace hex::ui {
for (auto &pattern : patterns) {
std::vector<std::string> patternPath;
size_t startFavoriteCount = m_favorites.size();
traversePatternTree(*pattern, patternPath, [&, this](const pl::ptrn::Pattern &currPattern) {
if (currPattern.hasAttribute("hex::favorite"))
m_favorites.insert({ patternPath, currPattern.clone() });
@ -1394,12 +1396,15 @@ namespace hex::ui {
m_groups[groupName].push_back(currPattern.clone());
}
task.update();
});
if (updatedFavorites == m_favorites.size())
task.interrupt();
task.update();
if (startFavoriteCount == m_favorites.size())
continue;
patternPath.clear();
traversePatternTree(*pattern, patternPath, [&, this](const pl::ptrn::Pattern &currPattern) {
for (auto &[path, favoritePattern] : m_favorites) {