Skip to content

Return instead of co_await in dispatch_setup_packet - #2

Merged
kammce merged 1 commit into
mainfrom
flatten-dispatch-setup-packet
Aug 23, 2026
Merged

Return instead of co_await in dispatch_setup_packet#2
kammce merged 1 commit into
mainfrom
flatten-dispatch-setup-packet

Conversation

@kammce

@kammce kammce commented Aug 23, 2026

Copy link
Copy Markdown
Member

Summary

  • dispatch_setup_packet() is a switch where every branch does exactly one async call and nothing else before or after it. It doesn't own any local state the async chain depends on (p_request is a reference into the caller's frame). That means it can return the chosen call's future directly instead of co_await-ing it, dropping its own coroutine frame/resume-state machinery entirely.
  • Measured on the libhal-arm-mcu v2 USB CDC demo: 75,373 → 74,949 bytes flash (.text+.rodata+unwind tables), a 424 byte reduction, with no behavior change.

Test plan

  • conan create . -pr:a hal/tc/llvm -pr hal/mcu/stm32f103zg --build=missing — builds and test_package runs
  • Rebuilt libhal-arm-mcu's demos against this version — all 8 demos build clean, USB CDC demo confirmed smaller

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.
@kammce
kammce merged commit 9082a00 into main Aug 23, 2026
0 of 9 checks passed
@kammce
kammce deleted the flatten-dispatch-setup-packet branch August 23, 2026 14:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant