1
0
mirror of https://github.com/esphome/esphome.git synced 2025-10-08 12:53:45 +01:00

[core] Skip redundant process_to_add() call when no scheduler items added

This commit is contained in:
J. Nick Koston
2025-09-06 22:52:48 -05:00
parent 4d09932320
commit 57fd7552e3

View File

@@ -326,6 +326,9 @@ void HOT Scheduler::call(uint32_t now) {
const auto now_64 = this->millis_64_(now); // 'now' from parameter - fresh from Application::loop() const auto now_64 = this->millis_64_(now); // 'now' from parameter - fresh from Application::loop()
this->process_to_add(); this->process_to_add();
// Track if we add any interval items during this call
bool added_intervals = false;
#ifdef ESPHOME_DEBUG_SCHEDULER #ifdef ESPHOME_DEBUG_SCHEDULER
static uint64_t last_print = 0; static uint64_t last_print = 0;
@@ -470,10 +473,14 @@ void HOT Scheduler::call(uint32_t now) {
// since we have the lock held // since we have the lock held
this->to_add_.push_back(std::move(item)); this->to_add_.push_back(std::move(item));
} }
added_intervals |= this->to_add_.empty() == false;
} }
} }
if (added_intervals) {
this->process_to_add(); this->process_to_add();
}
} }
void HOT Scheduler::process_to_add() { void HOT Scheduler::process_to_add() {
LockGuard guard{this->lock_}; LockGuard guard{this->lock_};