Skip to content

Commit 6271495

Browse files
committed
Shrink the opstate by a pointer
Make `__synthetic_coro_frame` a byte smaller so the `bool __started_` member in `__opstate` can sneak into the trailing padding, saving a pointer.
1 parent d1c3308 commit 6271495

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

include/stdexec/__detail/__connect_awaitable.hpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,11 @@ namespace STDEXEC
7474
struct __synthetic_coro_frame
7575
{
7676
void (*__resume_)(void*) noexcept;
77-
void (*__destroy_)(void*) noexcept = nullptr;
77+
// a coroutine frame is usually headed by two function pointers, resume and destroy
78+
// in our use, below, we never invoke destroy so there's no need to actually store
79+
// it; instead, leave some padding at the end of the struct so we can use its last
80+
// byte to store a bool indicating whether or not we ever started the operation
81+
std::byte __padding_[sizeof(void*) - 1]{};
7882
};
7983

8084
static constexpr std::ptrdiff_t __promise_offset = sizeof(__synthetic_coro_frame);

0 commit comments

Comments
 (0)