From df5193ff733d71eeee8f5b8f0832bdfccf58f340 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Fri, 19 Dec 2025 20:11:21 -1000 Subject: [PATCH] fix merge --- esphome/core/helpers.h | 44 ------------------------------------------ 1 file changed, 44 deletions(-) diff --git a/esphome/core/helpers.h b/esphome/core/helpers.h index 9c6c983fe8..bd79cf255e 100644 --- a/esphome/core/helpers.h +++ b/esphome/core/helpers.h @@ -1008,50 +1008,6 @@ template class LazyCallbackManager { std::unique_ptr> callbacks_; }; -template class LazyCallbackManager; - -/** Lazy-allocating callback manager that only allocates memory when callbacks are registered. - * - * This is a drop-in replacement for CallbackManager that saves memory when no callbacks - * are registered (common case after the Controller Registry eliminated per-entity callbacks - * from API and web_server components). - * - * Memory overhead comparison (32-bit systems): - * - CallbackManager: 12 bytes (empty std::vector) - * - LazyCallbackManager: 4 bytes (nullptr unique_ptr) - * - * @tparam Ts The arguments for the callbacks, wrapped in void(). - */ -template class LazyCallbackManager { - public: - /// Add a callback to the list. Allocates the underlying CallbackManager on first use. - void add(std::function &&callback) { - if (!this->callbacks_) { - this->callbacks_ = make_unique>(); - } - this->callbacks_->add(std::move(callback)); - } - - /// Call all callbacks in this manager. No-op if no callbacks registered. - void call(Ts... args) { - if (this->callbacks_) { - this->callbacks_->call(args...); - } - } - - /// Return the number of registered callbacks. - size_t size() const { return this->callbacks_ ? this->callbacks_->size() : 0; } - - /// Check if any callbacks are registered. - bool empty() const { return !this->callbacks_ || this->callbacks_->size() == 0; } - - /// Call all callbacks in this manager. - void operator()(Ts... args) { this->call(args...); } - - protected: - std::unique_ptr> callbacks_; -}; - /// Helper class to deduplicate items in a series of values. template class Deduplicator { public: