mirror of
https://github.com/esphome/esphome.git
synced 2026-09-01 18:46:02 +00:00
Use pointer-to-pointer idiom in add_action() for consistency
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user