From 5e7895bf261fa81c963a0696f699de9f75f0f985 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Wed, 1 Apr 2026 14:23:47 -1000 Subject: [PATCH] [core] Force inline Component::get_component_log_str() Move get_component_log_str() from component.cpp into the header as an always_inline method. This is a trivial one-liner that just calls component_source_lookup(), but the compiler was keeping it out-of-line across 8 call sites (13 bytes). Saves 8 bytes on ESP32. --- esphome/core/component.cpp | 3 --- esphome/core/component.h | 4 +++- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/esphome/core/component.cpp b/esphome/core/component.cpp index 955596ce95..c27a30d776 100644 --- a/esphome/core/component.cpp +++ b/esphome/core/component.cpp @@ -267,9 +267,6 @@ void Component::call() { break; } } -const LogString *Component::get_component_log_str() const { - return component_source_lookup(this->component_source_index_); -} bool Component::should_warn_of_blocking(uint32_t blocking_time) { // Convert centisecond threshold to milliseconds for comparison uint32_t threshold_ms = static_cast(this->warn_if_blocking_over_) * 10U; diff --git a/esphome/core/component.h b/esphome/core/component.h index c5a331ee29..d34fce8856 100644 --- a/esphome/core/component.h +++ b/esphome/core/component.h @@ -323,7 +323,9 @@ class Component { * * Returns LOG_STR("") if source not set */ - const LogString *get_component_log_str() const; + inline const LogString *get_component_log_str() const ESPHOME_ALWAYS_INLINE { + return component_source_lookup(this->component_source_index_); + } bool should_warn_of_blocking(uint32_t blocking_time);