From c17a3b6fccb5ea0b782ef06cc6c9508702ec471e Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Sun, 15 Jun 2025 16:34:37 -0500 Subject: [PATCH] Reduce Component memory usage by 20 bytes per component (#9080) Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com> --- esphome/core/component.cpp | 3 ++- esphome/core/component.h | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/esphome/core/component.cpp b/esphome/core/component.cpp index 03c44599e2..0a4606074a 100644 --- a/esphome/core/component.cpp +++ b/esphome/core/component.cpp @@ -85,7 +85,8 @@ void Component::call_setup() { this->setup(); } void Component::call_dump_config() { this->dump_config(); if (this->is_failed()) { - ESP_LOGE(TAG, " Component %s is marked FAILED: %s", this->get_component_source(), this->error_message_.c_str()); + ESP_LOGE(TAG, " Component %s is marked FAILED: %s", this->get_component_source(), + this->error_message_ ? this->error_message_ : "unspecified"); } } diff --git a/esphome/core/component.h b/esphome/core/component.h index d05a965034..f77d40ae35 100644 --- a/esphome/core/component.h +++ b/esphome/core/component.h @@ -319,7 +319,7 @@ class Component { float setup_priority_override_{NAN}; const char *component_source_{nullptr}; uint16_t warn_if_blocking_over_{WARN_IF_BLOCKING_OVER_MS}; ///< Warn if blocked for this many ms (max 65.5s) - std::string error_message_{}; + const char *error_message_{nullptr}; }; /** This class simplifies creating components that periodically check a state.