From f1bc3c68ddf7ae8e83dd301db39434af234a88c5 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Fri, 14 Nov 2025 20:09:38 -0600 Subject: [PATCH] [core] Optimize DelayAction for no-argument case using if constexpr --- esphome/core/base_automation.h | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/esphome/core/base_automation.h b/esphome/core/base_automation.h index 4a7f550b22..c2519da839 100644 --- a/esphome/core/base_automation.h +++ b/esphome/core/base_automation.h @@ -192,12 +192,7 @@ template class DelayAction : public Action, public Compon if constexpr (sizeof...(Ts) == 0) { App.scheduler.set_timer_common_( this, Scheduler::SchedulerItem::TIMEOUT, - /* is_static_string= */ true, "delay", this->delay_.value(), - [this]() { - if (this->num_running_ > 0) { - this->play_next_(); - } - }, + /* is_static_string= */ true, "delay", this->delay_.value(), [this]() { this->play_next_(); }, /* is_retry= */ false, /* skip_cancel= */ this->num_running_ > 1); } else { // For delays with arguments, use std::bind to preserve argument values