From e3e5f40a96b37dbcea96851a76c42be850231951 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Sat, 28 Mar 2026 10:46:04 -1000 Subject: [PATCH] Revert "Use pointer-to-pointer idiom in add_action() for consistency" This reverts commit db42403494bcb48323bad0618cfdae37bf828712. --- esphome/core/automation.h | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/esphome/core/automation.h b/esphome/core/automation.h index 90711cfaee7..72bcc3d7079 100644 --- a/esphome/core/automation.h +++ b/esphome/core/automation.h @@ -419,11 +419,15 @@ template class Action { template class ActionList { public: void add_action(Action *action) { - // Walk to end of chain - action lists are short and only built during setup() - Action **tail = &this->actions_begin_; - while (*tail != nullptr) - tail = &(*tail)->next_; - *tail = 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; + } } void add_actions(const std::initializer_list *> &actions) { // Find tail once, then append all actions in a single pass