1
0
mirror of https://github.com/oliverbooth/X10D synced 2024-11-09 23:25:43 +00:00

perf: accept ReadOnlySpan<byte> in WriteInternal

This method does not mutate the input span in any way, and so its input can be read-only.
This commit is contained in:
Oliver Booth 2023-04-01 17:11:47 +01:00
parent 2815c505c3
commit 990f860b39
No known key found for this signature in database
GPG Key ID: 20BEB9DC87961025

View File

@ -1,4 +1,4 @@
using System.Buffers.Binary; using System.Buffers.Binary;
using System.Reflection; using System.Reflection;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Security.Cryptography; using System.Security.Cryptography;
@ -1147,7 +1147,7 @@ public static class StreamExtensions
return (int)(stream.Position - preWritePosition); return (int)(stream.Position - preWritePosition);
} }
private static int WriteInternal(this Stream stream, Span<byte> value) private static int WriteInternal(this Stream stream, ReadOnlySpan<byte> value)
{ {
long preWritePosition = stream.Position; long preWritePosition = stream.Position;
stream.Write(value); stream.Write(value);