Use pointer-to-pointer idiom in add_action() for consistency

This commit is contained in:
J. Nick Koston
2026-03-28 10:39:06 -10:00
parent 0c313dbe66
commit db42403494
+5 -9
View File
@@ -419,15 +419,11 @@ template<typename... Ts> class Action {
template<typename... Ts> class ActionList {
public:
void add_action(Action<Ts...> *action) {
if (this->actions_begin_ == nullptr) {
this->actions_begin_ = action;
} else {
// Walk to end of chain - action lists are short and only built during setup()
auto *it = this->actions_begin_;
while (it->next_ != nullptr)
it = it->next_;
it->next_ = action;
}
// Walk to end of chain - action lists are short and only built during setup()
Action<Ts...> **tail = &this->actions_begin_;
while (*tail != nullptr)
tail = &(*tail)->next_;
*tail = action;
}
void add_actions(const std::initializer_list<Action<Ts...> *> &actions) {
// Find tail once, then append all actions in a single pass