[binary_sensor] Inline send_state_internal - virtual dispatch prevents template bloat

This commit is contained in:
J. Nick Koston
2026-03-22 16:38:38 -10:00
parent 0417de007a
commit 3fd28eeea2
2 changed files with 1 additions and 5 deletions
@@ -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<bool> &new_state) {
if (StatefulEntityBase::set_new_state(new_state)) {
#if defined(USE_BINARY_SENSOR) && defined(USE_CONTROLLER_REGISTRY)
@@ -57,7 +57,7 @@ class BinarySensor : public StatefulEntityBase<bool> {
// ========== 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;