mirror of
https://github.com/esphome/esphome.git
synced 2026-09-13 16:18:41 +00:00
bfc5a210bcb06b4c6e18b8ada8c71434c4518245
Replace std::function with a lightweight type-erased Callback struct (8 bytes on 32-bit vs 16 for std::function) in CallbackManager and LazyCallbackManager. Using C++20 if constexpr, small trivially-copyable callables like [this] lambdas (81% of all callback registrations) are stored inline in the function pointer context without heap allocation. This eliminates std::function null checks (and __throw_bad_function_call) from all entity callback paths, and templatizes add_on_*_callback methods across all entity types so lambdas flow through without being wrapped in std::function first. Also converts EntityStateBase from hand-rolled nullable CallbackManager pointers to LazyCallbackManager for consistency. Measured flash savings: - ESP8266 simple: -160 B - ESP8266 ratgdo: -592 B - ESP32 IDF (large): -456 B - ESP32 IDF (minimal): -212 B
Description
ESPHome is a system to control your ESP8266/ESP32 by simple yet powerful configuration files and control them remotely through Home Automation systems.
Readme
Multiple Licenses
593 MiB
Languages
C++
55.8%
Python
43.6%
C
0.3%
JavaScript
0.2%
