J. Nick Koston d8e586609f [core] Optimize value_accuracy_to_buf to avoid snprintf
Replace snprintf("%.*f") with integer-based formatting for finite
float values with accuracy_decimals 0-3 (covers virtually all sensor
usage). Falls back to snprintf for higher accuracy or NaN/Inf.

Uses lrint() with double cast for the multiply to match snprintf's
rounding behavior exactly. The fast path avoids snprintf's heavy
float formatting machinery entirely.

Also optimizes value_accuracy_with_uom_to_buf to append the UOM
string directly instead of going through snprintf.

Adds C++ unit tests that verify output matches snprintf for a range
of values including edge cases.

Benchmark: 92,961ns -> 6,484ns (14.3x faster, 2000 iterations).
2026-04-08 20:46:16 -10:00
2023-06-12 17:00:34 +12:00
2022-09-06 15:48:01 +12:00
2025-12-21 09:26:03 -05:00
2024-03-28 10:20:51 +13:00
2025-07-17 22:40:28 +12:00
2026-04-07 22:29:55 +00:00
2025-12-08 14:37:45 -05:00
2026-04-09 11:28:48 +12:00
2025-07-17 22:40:28 +12:00
S
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 546 MiB
Languages
C++ 60.1%
Python 39.3%
C 0.3%
JavaScript 0.2%