From 7b15b9a01741a90d1a221db322064ca96a049a49 Mon Sep 17 00:00:00 2001 From: Hirek193 Date: Wed, 7 Oct 2026 16:10:38 +0200 Subject: [PATCH] perf(scenery): minimap semaphores matched against the named models of a group collected once, instead of a search through all nodes of the scenery for each semaphore --- scene/scenenodegroups.cpp | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/scene/scenenodegroups.cpp b/scene/scenenodegroups.cpp index 2e786a79..3ed357f3 100644 --- a/scene/scenenodegroups.cpp +++ b/scene/scenenodegroups.cpp @@ -107,6 +107,11 @@ node_groups::update_map() for (auto const &pair : m_groupmap) { auto const &group = pair.second; + // named models of the group, collected once the group turns out to hold a semaphore. + // nested groups are flattened, so a group can hold millions of nodes, most of them nameless scenery; + // going through all of them for each semaphore took minutes + std::vector namedmodels; + bool namedmodelscollected = false; for (basic_node *node : group.nodes) { std::string postfix { "_sem_mem" }; @@ -128,10 +133,17 @@ node_groups::update_map() } } - for (basic_node *node : group.nodes) - if (auto *model = dynamic_cast(node)) - if (model->name().starts_with(sem_name)) - sem_info->models.push_back(model); + if (false == namedmodelscollected) { + for (basic_node *groupnode : group.nodes) + if (false == groupnode->name().empty()) + if (auto *model = dynamic_cast(groupnode)) + namedmodels.push_back(model); + namedmodelscollected = true; + } + + for (auto *model : namedmodels) + if (model->name().starts_with(sem_name)) + sem_info->models.push_back(model); } if (Global.map_manualswitchcontrol) {