-
Notifications
You must be signed in to change notification settings - Fork 5.4k
[SRM] Miscellaneous clean-up. #127308
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
Merged
Merged
[SRM] Miscellaneous clean-up. #127308
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
695c8c0
Remove unused or redundant code.
teo-tsirpanis ee142b8
Use `ArrayPool` in all frameworks.
teo-tsirpanis 69ae224
Use framework APIs to check for surrogate characters.
teo-tsirpanis fe9f9f0
Replace most uses of `BlobUtilities.GetUTF8ByteCount` with `Encoding.…
teo-tsirpanis a9c1c19
Return reused instances of immutable virtual blob buffers.
teo-tsirpanis b3ddb4b
Use immutable array builders in a couple of occasions.
teo-tsirpanis 4ec8f0c
Remove one instance of unsafe code.
teo-tsirpanis 3011f57
Use polyfill for `Stream.ReadAtLeast`.
teo-tsirpanis 471a0fa
Move the polyfill to its own file.
teo-tsirpanis 242e015
Remove double zeroing of reserved blob.
teo-tsirpanis ec61b49
Don't write data byte-by-byte.
teo-tsirpanis File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| using System.Buffers; | ||
|
|
||
| namespace System.IO; | ||
|
|
||
| /// <summary>Provides downlevel polyfills for Span-based instance methods on <see cref="Stream"/>.</summary> | ||
| internal static class StreamSpanPolyfills | ||
| { | ||
| extension(Stream stream) | ||
| { | ||
| public int ReadAtLeast(Span<byte> destination, int minimumBytes, bool throwOnEndOfStream = true) | ||
| { | ||
| byte[] buffer = ArrayPool<byte>.Shared.Rent(Math.Min(destination.Length, 81920)); | ||
| int totalWritten = 0; | ||
| while (totalWritten < minimumBytes && !destination.IsEmpty) | ||
| { | ||
| int written = stream.Read(buffer, 0, Math.Min(buffer.Length, destination.Length)); | ||
| if (written == 0) | ||
| { | ||
| if (throwOnEndOfStream) | ||
| { | ||
| ThrowEndOfStreamException(); | ||
| } | ||
| break; | ||
| } | ||
| buffer.AsSpan(0, written).CopyTo(destination); | ||
| totalWritten += written; | ||
| destination = destination.Slice(written); | ||
| } | ||
| ArrayPool<byte>.Shared.Return(buffer); | ||
| return totalWritten; | ||
|
|
||
| static void ThrowEndOfStreamException() => throw new EndOfStreamException(); | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 0 additions & 60 deletions
60
...Reflection.Metadata/src/System/Reflection/Internal/Utilities/EncodingHelper.netcoreapp.cs
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.