diff --git a/esphome/components/runtime_stats/runtime_stats.cpp b/esphome/components/runtime_stats/runtime_stats.cpp index 9d87534fec..8f5d5daf01 100644 --- a/esphome/components/runtime_stats/runtime_stats.cpp +++ b/esphome/components/runtime_stats/runtime_stats.cpp @@ -25,17 +25,13 @@ void RuntimeStatsCollector::record_component_time(Component *component, uint32_t this->component_names_cache_[component] = source; this->component_stats_[source].record_time(duration_ms); } else { - // Use cached name - no string operations, just map lookup this->component_stats_[name_it->second].record_time(duration_ms); } - // If next_log_time_ is 0, initialize it if (this->next_log_time_ == 0) { this->next_log_time_ = current_time + this->log_interval_; return; } - - // Don't print stats here anymore - let process_pending_stats handle it } void RuntimeStatsCollector::log_stats_() { diff --git a/esphome/components/runtime_stats/runtime_stats.h b/esphome/components/runtime_stats/runtime_stats.h index 36572e2094..20b0c08313 100644 --- a/esphome/components/runtime_stats/runtime_stats.h +++ b/esphome/components/runtime_stats/runtime_stats.h @@ -111,6 +111,8 @@ class RuntimeStatsCollector { // Use const char* keys for efficiency // Custom comparator for const char* keys in map + // Without this, std::map would compare pointer addresses instead of string contents, + // causing identical component names at different addresses to be treated as different keys struct CStrCompare { bool operator()(const char *a, const char *b) const { return std::strcmp(a, b) < 0; } };