-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using stackalloc instead of new byte[x] on Streams #88303
Conversation
This reverts commit 449fdde.
...DataContractSerialization/src/System/Runtime/Serialization/Json/JsonEncodingStreamWrapper.cs
Outdated
Show resolved
Hide resolved
Tagging subscribers to this area: @dotnet/area-system-io Issue DetailsReplace new[] allocations with stackalloc for one byte array in different Stream classes.
|
Thanks, but these are all async methods accepting Memory, not Span. You can't pass a stackalloc'd span to them. This will not compile. |
How could I missed that ! Fixed :) - rollback for DecompressionHandler - Other changes seem fine. |
src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/DecompressionHandler.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Net.Security/src/System/Net/Security/SslStream.cs
Outdated
Show resolved
Hide resolved
...DataContractSerialization/src/System/Runtime/Serialization/Json/JsonEncodingStreamWrapper.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use the span constructors introduced in .NET 7 instead of stackalloc
.
...DataContractSerialization/src/System/Runtime/Serialization/Json/JsonEncodingStreamWrapper.cs
Outdated
Show resolved
Hide resolved
...DataContractSerialization/src/System/Runtime/Serialization/Json/JsonEncodingStreamWrapper.cs
Outdated
Show resolved
Hide resolved
...DataContractSerialization/src/System/Runtime/Serialization/Json/JsonEncodingStreamWrapper.cs
Show resolved
Hide resolved
...DataContractSerialization/src/System/Runtime/Serialization/Json/JsonEncodingStreamWrapper.cs
Show resolved
Hide resolved
...DataContractSerialization/src/System/Runtime/Serialization/Json/JsonEncodingStreamWrapper.cs
Outdated
Show resolved
Hide resolved
...DataContractSerialization/src/System/Runtime/Serialization/Json/JsonEncodingStreamWrapper.cs
Outdated
Show resolved
Hide resolved
...DataContractSerialization/src/System/Runtime/Serialization/Json/JsonEncodingStreamWrapper.cs
Outdated
Show resolved
Hide resolved
...DataContractSerialization/src/System/Runtime/Serialization/Json/JsonEncodingStreamWrapper.cs
Outdated
Show resolved
Hide resolved
…tem/Runtime/Serialization/Json/JsonEncodingStreamWrapper.cs replace Span by ReadOnlySpan Co-authored-by: Michał Petryka <35800402+MichalPetryka@users.noreply.github.com>
...DataContractSerialization/src/System/Runtime/Serialization/Json/JsonEncodingStreamWrapper.cs
Outdated
Show resolved
Hide resolved
...DataContractSerialization/src/System/Runtime/Serialization/Json/JsonEncodingStreamWrapper.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other than my remaining comments, LGTM.
…tem/Runtime/Serialization/Json/JsonEncodingStreamWrapper.cs Co-authored-by: Stephen Toub <stoub@microsoft.com>
…tem/Runtime/Serialization/Json/JsonEncodingStreamWrapper.cs Co-authored-by: Stephen Toub <stoub@microsoft.com>
Replace new[] allocations with stackalloc for one byte array in different Stream classes.
I don't think there will be a big performance change at the CPU level but it will always be a gain on the garbage collector