1
0
mirror of https://github.com/esphome/esphome.git synced 2026-02-08 08:41:59 +00:00

[template.text] Avoid heap allocation for trigger

This commit is contained in:
J. Nick Koston
2026-02-02 05:03:30 +01:00
parent 18c152723c
commit 6cfce56f98

View File

@@ -68,7 +68,7 @@ class TemplateText final : public text::Text, public PollingComponent {
void dump_config() override;
float get_setup_priority() const override { return setup_priority::HARDWARE; }
Trigger<std::string> *get_set_trigger() const { return this->set_trigger_; }
Trigger<std::string> *get_set_trigger() { return &this->set_trigger_; }
void set_optimistic(bool optimistic) { this->optimistic_ = optimistic; }
void set_initial_value(const char *initial_value) { this->initial_value_ = initial_value; }
/// Prevent accidental use of std::string which would dangle
@@ -79,7 +79,7 @@ class TemplateText final : public text::Text, public PollingComponent {
void control(const std::string &value) override;
bool optimistic_ = false;
const char *initial_value_{nullptr};
Trigger<std::string> *set_trigger_ = new Trigger<std::string>();
Trigger<std::string> set_trigger_;
TemplateLambda<std::string> f_{};
TemplateTextSaverBase *pref_ = nullptr;