mirror of
https://github.com/esphome/esphome.git
synced 2026-09-15 09:08:41 +00:00
36881166a8868676a48cc23350cfb9916b9cee99
The inlined `value < 0.0f || value > 1.0f` check in the clamp loop costs ~50 B per iteration on ESP8266 (two libgcc soft-float calls with register spills). IEEE 754 floats in [0.0f, 1.0f] have bit patterns in [0x00000000, 0x3F800000]; anything out of range — values > 1.0f, negatives (sign bit set → huge unsigned interpretation), NaN, Infinity — has a strictly larger unsigned interpretation. A single `pun.u > 0x3F800000u` covers every case. Using a union for the type-pun rather than memcpy/bit_cast because those don't optimize to a no-op on xtensa-gcc (same reason api/proto.h's float_to_raw() uses a union). The loop body is now two instructions for the range check: l32i a2, a9, 0 ; load raw u32 bgeu a10, a2, ... ; compare against pre-hoisted 1.0f bits Size delta vs. the prior float-compare form: ESP32-IDF: validate_ -16 B, net -12 B ESP8266: validate_ -20 B, net -20 B vs. dev baseline (isolated light build, matched funcs): ESP32-IDF: -103 B code, +32 B PROGMEM table = -71 B net ESP8266: -42 B code, +32 B PROGMEM table = -10 B net
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
594 MiB
Languages
C++
55.8%
Python
43.6%
C
0.3%
JavaScript
0.2%
