From 42fe39cfd9bd163ac7e2c26799164d6eef01ae2e Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Fri, 27 Mar 2026 16:24:23 -1000 Subject: [PATCH] Use pointer iteration in call() to avoid uint16_t movzx overhead on x86-64 --- esphome/core/helpers.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/esphome/core/helpers.h b/esphome/core/helpers.h index 47775dd43c..169028be1a 100644 --- a/esphome/core/helpers.h +++ b/esphome/core/helpers.h @@ -1834,8 +1834,9 @@ template class CallbackManager { /// Call all callbacks in this manager. void call(Ts... args) { - for (uint16_t i = 0; i < this->size_; i++) - this->data_[i].call(args...); + for (auto *it = this->data_, *end = it + this->size_; it != end; ++it) { + it->call(args...); + } } uint16_t size() const { return this->size_; }