J. Nick Koston 58f8029264 [wifi] Use memcpy-based insertion sort for scan results
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.
2026-02-12 12:29:19 -06:00
2026-02-11 22:11:48 -05: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
2025-12-08 14:37:45 -05:00
2026-02-12 23:04:19 +13:00
2025-07-17 22:40:28 +12:00
2026-02-11 22:11:48 -05:00
2025-12-05 08:48:04 -05:00
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%