Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Combine ExecutionContext/CapturedContext fields in ManualResetValueTa…
…skSourceCore (#82181) There's currently an _executionContext field and a _capturedContext field. Both of these are for non-fast-path. This not only means the struct is larger than is necessary for the common case, it also means when we reset the instance between operations we need to clear an extra field, and it means we have an extra branch on some paths to check both fields. We can instead combine them into a single field. We allocate an extra tuple object if there's both an ExecutionContext and a scheduler, but this is exceedingly rare: when used as part of awaits, there will never be an ExecutionContext, so this will only happen in situations where someone is directly using the awaiter's OnCompleted (not UnsafeOnCompleted) method and there's a scheduler and ConfigureAwait(false) wasn't used. Such a situation not only is rare, it also already has additional overheads. This also cleans up a bit about how exceptions are handled and moves more logic out of the generic type to avoid code bloat with generic instantiations.
- Loading branch information