mirror of
https://github.com/esphome/esphome.git
synced 2026-09-20 19:48:39 +00:00
[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
This commit is contained in:
@@ -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_();
|
||||
|
||||
Reference in New Issue
Block a user