mirror of
https://github.com/BepInEx/dotnet-runtime.git
synced 2026-11-25 10:58:20 -10:00
Most HttpContents produce the Stream from CreateContentReadStreamAsync synchronously, which means CreateContentReadStreamAsync is allocating a Task to wrap that stream unnecessarily. While we can't change the existing protected API to return ValueTask instead of Task, we can add an internal API that we use instead. The new base virtual just delegates to the existing Task-based overload. Then derived implementations can override this; such derived implementations can just do the more efficient thing if they're sealed, or if they're not sealed, do so when they're sure a derived type isn't overriding the delegated implementation, e.g. by checking the concrete type of the instance. Commit migrated from https://github.com/dotnet/corefx/commit/01abf38cac641981db1cbbf74012ddbbf0d768df