From 942cb0733b67d2e72a65c9a8e908f1ef33ab611f Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Sun, 12 Apr 2026 17:26:00 -1000 Subject: [PATCH] [scheduler] Force-inline cleanup_() fast path into Scheduler::call() cleanup_() has a two-line fast path (check to_remove count, return !items_.empty()) with the slow path already out-of-line in cleanup_slow_path_(). Despite `inline` hint, GCC on Xtensa emits it as a separate function, adding unnecessary call overhead on every Scheduler::call() invocation even when there is nothing to clean up. Use ESPHOME_ALWAYS_INLINE to guarantee inlining. Verified on ESP8266: - cleanup_() symbol eliminated from binary - Scheduler::call() grows 4 bytes (inlined fast path) - Net savings: 23 bytes (27-byte out-of-line body removed) - Idle loop path: 1 out-of-line call instead of 2 --- esphome/core/scheduler.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/esphome/core/scheduler.h b/esphome/core/scheduler.h index 43a3ec7049b..81ff6abadcb 100644 --- a/esphome/core/scheduler.h +++ b/esphome/core/scheduler.h @@ -302,7 +302,7 @@ class Scheduler { // loop thread structurally modifies items_ (push/pop/erase). Other threads may // iterate items_ and mark items removed under lock_, but never change the // vector's size or data pointer. - inline bool HOT cleanup_() { + inline bool ESPHOME_ALWAYS_INLINE HOT cleanup_() { if (this->to_remove_empty_()) return !this->items_.empty(); return this->cleanup_slow_path_();