From 6f3b2b32f7be2324c774dce0b65247540ff296a0 Mon Sep 17 00:00:00 2001 From: Khalil Estell Date: Sun, 23 Aug 2026 07:13:33 -0700 Subject: [PATCH] Return instead of co_await in dispatch_setup_packet Every branch hands off to exactly one async call with nothing else in the function, so it can return that call's future directly instead of paying for its own coroutine frame/resume state just to await and immediately finish. --- v1/modules/enumerator.cppm | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/v1/modules/enumerator.cppm b/v1/modules/enumerator.cppm index ee3f6dc..0a5b59b 100644 --- a/v1/modules/enumerator.cppm +++ b/v1/modules/enumerator.cppm @@ -458,24 +458,27 @@ private: co_await dispatch_setup_packet(p_context, request); } + // Not a coroutine: every branch hands off to exactly one async call and + // does nothing else, so this can return that call's future directly + // instead of paying for its own coroutine frame/resume state to just + // await and immediately finish. hal::task dispatch_setup_packet(async::context& p_context, setup_packet& p_request) { switch (p_request.get_recipient()) { case setup_packet::request_recipient::invalid: - co_await send_error_to_host(p_context); - break; + return send_error_to_host(p_context); case setup_packet::request_recipient::device: - co_await handle_standard_device_request(p_context, p_request); - break; + return handle_standard_device_request(p_context, p_request); case setup_packet::request_recipient::interface: [[fallthrough]]; case setup_packet::request_recipient::endpoint: - co_await handle_interface_request(p_context, p_request); - break; + return handle_interface_request(p_context, p_request); } + + return {}; } hal::task handle_interface_request(async::context& p_context,