mirror of
https://github.com/esphome/esphome.git
synced 2026-09-15 17:18:40 +00:00
[core] Limit play_complex override to StatelessLambdaAction only
LambdaAction and ContinuationAction overrides caused flash bloat by replacing shared base class play_complex instantiations with per-class copies. StatelessLambdaAction is the most common automation action and its no-args variant is only 24 bytes.
This commit is contained in:
@@ -217,13 +217,6 @@ template<typename... Ts> class LambdaAction : public Action<Ts...> {
|
||||
public:
|
||||
explicit LambdaAction(std::function<void(Ts...)> &&f) : f_(std::move(f)) {}
|
||||
|
||||
// Override play_complex to call play() non-virtually (qualified call),
|
||||
// eliminating one virtual dispatch frame from the call stack.
|
||||
void play_complex(const Ts &...x) override {
|
||||
this->num_running_++;
|
||||
LambdaAction::play(x...);
|
||||
this->play_next_(x...);
|
||||
}
|
||||
void play(const Ts &...x) override { this->f_(x...); }
|
||||
|
||||
protected:
|
||||
@@ -257,13 +250,6 @@ template<typename... Ts> class ContinuationAction : public Action<Ts...> {
|
||||
public:
|
||||
explicit ContinuationAction(Action<Ts...> *parent) : parent_(parent) {}
|
||||
|
||||
// Override play_complex to call play() non-virtually (qualified call),
|
||||
// eliminating one virtual dispatch frame from the call stack.
|
||||
void play_complex(const Ts &...x) override {
|
||||
this->num_running_++;
|
||||
ContinuationAction::play(x...);
|
||||
this->play_next_(x...);
|
||||
}
|
||||
void play(const Ts &...x) override { this->parent_->play_next_(x...); }
|
||||
|
||||
protected:
|
||||
|
||||
Reference in New Issue
Block a user