1
0
mirror of synced 2024-11-30 18:34:29 +01:00

impr: Optimization for searching for favorite and group patterns

This commit is contained in:
WerWolv 2024-11-24 23:21:23 +01:00
parent fe9eecd031
commit d167e43252
2 changed files with 5 additions and 3 deletions

@ -1 +1 @@
Subproject commit f9eed4b7ad1f6f50f25f9fd4222be325885e8c4e
Subproject commit 9a02bd862fc8a4768a152a31a0175145fc48b0a2

View File

@ -1392,15 +1392,17 @@ namespace hex::ui {
m_favoritesUpdateTask = TaskManager::createTask("hex.ui.pattern_drawer.updating"_lang, TaskManager::NoProgress, [this, patterns](auto &task) {
size_t updatedFavorites = 0;
const std::string favoriteAttribute = "hex::favorite";
const std::string groupAttribute = "hex::group";
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"))
if (currPattern.hasAttribute(favoriteAttribute))
m_favorites.insert({ patternPath, currPattern.clone() });
if (const auto &args = currPattern.getAttributeArguments("hex::group"); !args.empty()) {
if (const auto &args = currPattern.getAttributeArguments(groupAttribute); !args.empty()) {
auto groupName = args.front().toString();
if (!m_groups.contains(groupName))