mirror of
https://github.com/esphome/esphome.git
synced 2026-02-15 22:09:36 -07:00
58f80292642dc5a4e23fde673ed06c7b8ebc5fcb
Replace copy-assignment with raw memcpy in the WiFi scan result insertion sort. Copy assignment on WiFiScanResult calls CompactString's destructor then placement-new for every shift, which means delete[]/new[] per shift for heap-allocated SSIDs. With 70+ networks visible (e.g., during captive portal transition showing full scan results), this caused event loop blocking from hundreds of heap allocations in a tight loop on an 80MHz ESP8266. This optimization is safe because we're permuting elements within the same array - each slot is overwritten exactly once, so no ownership duplication occurs. CompactString stores either inline data or a heap pointer, never a self-referential pointer (unlike libstdc++ std::string SSO). This was made possible by PR#13472 which replaced std::string with CompactString. Static asserts guard the memcpy safety assumptions at compile time. Confirmed on real device: event loop blocking during captive portal transition is eliminated and WiFi connection is slightly faster.
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
319 MiB
Languages
C++
64.2%
Python
35.5%
C
0.2%
