1
0
mirror of https://github.com/esphome/esphome.git synced 2026-02-08 00:31:58 +00:00
J. Nick Koston f9542236e8 [udp] Eliminate per-loop heap allocation by using std::span for packet callbacks
Replace std::vector<uint8_t> with std::array on the stack for the receive
buffer and std::span<const uint8_t> for packet listener callbacks. This
eliminates a 508-byte heap allocation on every loop() iteration, reducing
heap fragmentation on long-running devices.

The callback signature changes from std::vector<uint8_t>& to
std::span<const uint8_t>, which preserves API compatibility for user
lambdas using data.size(), data.data(), data[i], and range-for.

The trigger/automation type remains std::vector<uint8_t> so that deferred
actions (e.g. delay) safely own their data. The listener lambda converts
span to vector at the trigger boundary.

PacketTransport::process_() now takes std::span<const uint8_t> directly,
with implicit conversion from std::vector for other transports.
2026-02-07 11:24:31 +01: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-01-14 09:19:45 -05:00
2025-07-17 22:40:28 +12:00
2025-12-05 08:48:04 -05:00
Description
No description provided
Readme Multiple Licenses 282 MiB
Languages
C++ 64.3%
Python 35.4%
C 0.2%