Zero-copy decode: span-based Envelope and DecodedMessage, defer usb_rx_buf clear

This commit is contained in:
Ian Gulliver
2026-04-10 23:08:51 +09:00
parent 76c519c17a
commit 7264611f99
3 changed files with 12 additions and 7 deletions

View File

@@ -59,12 +59,11 @@ void dispatch_schedule_ms(uint32_t ms, std::function<void()> fn) {
continue;
}
usb_rx_buf.clear();
auto it = handler_map.find(msg->type_id);
if (it == handler_map.end()) continue;
if (it == handler_map.end()) { usb_rx_buf.clear(); continue; }
span_writer out(tx_buf);
auto resp = it->second(msg->message_id, msg->payload, out);
usb_rx_buf.clear();
if (!resp || *resp == 0) continue;
size_t resp_len = *resp;
if (resp_len <= usb.tx.free()) {