From 939b3d383ccf37d1e8637ed94896f182ccee1405 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Sun, 12 Apr 2026 17:47:31 -1000 Subject: [PATCH] [scheduler] Force-inline process_to_add() fast path process_to_add() has the same pattern as cleanup_(): a one-line inline fast path (check if to_add_ is empty) with the slow path already out-of-line in process_to_add_slow_path_(). GCC inlines it on ESP8266 but not on ESP32, emitting a 20-byte out-of-line body. Use ESPHOME_ALWAYS_INLINE to guarantee inlining on all platforms. Verified on ESP32 (xtensa-esp32): - process_to_add() symbol eliminated from binary - Scheduler::call() idle path: 1 out-of-line call (millis_64 only) --- 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 43a3ec7049..c68a71ca7b 100644 --- a/esphome/core/scheduler.h +++ b/esphome/core/scheduler.h @@ -138,7 +138,7 @@ class Scheduler { // (single-threaded). This is safe because the main loop is the only thread // that reads to_add_ without holding lock_; other threads may read it only // while holding the mutex (e.g. cancel_item_locked_). - inline void HOT process_to_add() { + inline void ESPHOME_ALWAYS_INLINE HOT process_to_add() { if (this->to_add_empty_()) return; this->process_to_add_slow_path_();