From 3fd28eeea208e08d59267c49056d91222e13a528 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Sun, 22 Mar 2026 16:38:38 -1000 Subject: [PATCH] [binary_sensor] Inline send_state_internal - virtual dispatch prevents template bloat --- esphome/components/binary_sensor/binary_sensor.cpp | 4 ---- esphome/components/binary_sensor/binary_sensor.h | 2 +- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/esphome/components/binary_sensor/binary_sensor.cpp b/esphome/components/binary_sensor/binary_sensor.cpp index 4d093b3630..a7b2f5ba91 100644 --- a/esphome/components/binary_sensor/binary_sensor.cpp +++ b/esphome/components/binary_sensor/binary_sensor.cpp @@ -32,10 +32,6 @@ void BinarySensor::publish_initial_state(bool new_state) { this->invalidate_state(); this->publish_state(new_state); } -// Defined out-of-line: set_new_state is virtual so callers in other TUs (filter.cpp, automation.h) -// dispatch here without inlining the ~189 byte template body at each call site. -void BinarySensor::send_state_internal(bool new_state) { this->set_new_state(new_state); } - bool BinarySensor::set_new_state(const optional &new_state) { if (StatefulEntityBase::set_new_state(new_state)) { #if defined(USE_BINARY_SENSOR) && defined(USE_CONTROLLER_REGISTRY) diff --git a/esphome/components/binary_sensor/binary_sensor.h b/esphome/components/binary_sensor/binary_sensor.h index 5ad2bd2edf..37362bc432 100644 --- a/esphome/components/binary_sensor/binary_sensor.h +++ b/esphome/components/binary_sensor/binary_sensor.h @@ -57,7 +57,7 @@ class BinarySensor : public StatefulEntityBase { // ========== INTERNAL METHODS ========== // (In most use cases you won't need these) - void send_state_internal(bool new_state); + void send_state_internal(bool new_state) { this->set_new_state(new_state); } /// Return whether this binary sensor has outputted a state. virtual bool is_status_binary_sensor() const;