Optimize add_actions() to find tail once instead of re-walking per action

This commit is contained in:
J. Nick Koston
2026-03-28 10:34:25 -10:00
parent 79d2d8e5c8
commit 0c313dbe66
+6 -1
View File
@@ -430,8 +430,13 @@ template<typename... Ts> class ActionList {
}
}
void add_actions(const std::initializer_list<Action<Ts...> *> &actions) {
// Find tail once, then append all actions in a single pass
Action<Ts...> **tail = &this->actions_begin_;
while (*tail != nullptr)
tail = &(*tail)->next_;
for (auto *action : actions) {
this->add_action(action);
*tail = action;
tail = &action->next_;
}
}
// Force-inline: part of the Trigger→Automation→ActionList forwarding