avoid extra heap allocation, its unconditionally allocated anyways

This commit is contained in:
J. Nick Koston
2026-02-02 03:08:01 +01:00
parent 7385150178
commit cf33a61e33
2 changed files with 7 additions and 7 deletions

View File

@@ -310,7 +310,7 @@ void EthernetComponent::loop() {
this->dump_connect_params_();
this->status_clear_warning();
#ifdef USE_ETHERNET_CONNECT_TRIGGER
this->connect_trigger_->trigger();
this->connect_trigger_.trigger();
#endif
} else if (now - this->connect_begin_ > 15000) {
ESP_LOGW(TAG, "Connecting failed; reconnecting");
@@ -322,14 +322,14 @@ void EthernetComponent::loop() {
ESP_LOGI(TAG, "Stopped connection");
this->state_ = EthernetComponentState::STOPPED;
#ifdef USE_ETHERNET_DISCONNECT_TRIGGER
this->disconnect_trigger_->trigger();
this->disconnect_trigger_.trigger();
#endif
} else if (!this->connected_) {
ESP_LOGW(TAG, "Connection lost; reconnecting");
this->state_ = EthernetComponentState::CONNECTING;
this->start_connect_();
#ifdef USE_ETHERNET_DISCONNECT_TRIGGER
this->disconnect_trigger_->trigger();
this->disconnect_trigger_.trigger();
#endif
} else {
this->finish_connect_();

View File

@@ -121,10 +121,10 @@ class EthernetComponent : public Component {
#endif
#ifdef USE_ETHERNET_CONNECT_TRIGGER
Trigger<> *get_connect_trigger() const { return this->connect_trigger_; }
Trigger<> *get_connect_trigger() { return &this->connect_trigger_; }
#endif
#ifdef USE_ETHERNET_DISCONNECT_TRIGGER
Trigger<> *get_disconnect_trigger() const { return this->disconnect_trigger_; }
Trigger<> *get_disconnect_trigger() { return &this->disconnect_trigger_; }
#endif
protected:
static void eth_event_handler(void *arg, esp_event_base_t event_base, int32_t event_id, void *event_data);
@@ -198,10 +198,10 @@ class EthernetComponent : public Component {
#endif
#ifdef USE_ETHERNET_CONNECT_TRIGGER
Trigger<> *connect_trigger_{new Trigger<>()};
Trigger<> connect_trigger_;
#endif
#ifdef USE_ETHERNET_DISCONNECT_TRIGGER
Trigger<> *disconnect_trigger_{new Trigger<>()};
Trigger<> disconnect_trigger_;
#endif
private:
// Stores a pointer to a string literal (static storage duration).