Add Stream
overrides for reading/writing spans to MemoryStream<TOwner>
#1052
Labels
feature request 📬
A request for new changes to improve functionality
Overview
The
Stream
class has default virtual methods for reading/writingSpan<T>
/ReadOnlySpan<T>
andMemory<T>
/ReadOnlyMemory<T>
that are very inefficient because they were added whenSpan<T>
/ReadOnlySpan<T>
andMemory<T>
/ReadOnlyMemory<T>
were added in .NET Core 2.1. These default methods allocate an array from the array pool, copy data into the array and then invoke thebyte[]
variant of the read/write method.The
MemoryStream<TOwner>
class should be updated to override theSpan<T>
/ReadOnlySpan<T>
andMemory<T>
/ReadOnlyMemory<T>
variants of the read/write methods to avoid this unnecessary overhead.API breakdown
Usage example
These are standard
Stream
methods that should be overridden. Standard usage for these methods.Breaking change?
No
Alternatives
No alternatives.
Additional context
No response
Help us help you
Yes, I'd like to be assigned to work on this item
The text was updated successfully, but these errors were encountered: