Details
-
Improvement
-
Resolution: Fixed
-
Major
-
None
-
1
Description
On .Net Core 2.0 and Full Framework, Stream doesn't have a ReadOnlySpan<byte> overload. As a result, in OperationBuilder so we're currently copying the entire span to another block of memory on the ArrayPool so we can call Write(byte[], int, int).
However, when the MemoryPool is used, it's typically backed under the covers by a byte[], and MemoryMarshal.TryGetArray can be used to extract an ArraySegment. Using this can cut out an ArrayPool allocation and a memory copy. We should test for this scenario and optimize for it.