-
Notifications
You must be signed in to change notification settings - Fork 763
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
Add Span support to WebEncoders #456
Comments
Hey @gfoidl, care to take a look at this one? Seems up your alley 😄 |
I'll have a look and try to route it down this alley 😄 |
@gfoidl some quick ideas:
|
Thanks for the pointers. I'll try to make progress over the weekend, today is at bit busy... To be sure: |
Correct |
It would be also good if the encoders supported encoding/decoding UTF8 buffers. |
We need to give the encoders an overhaul anyway when the UTF8 support comes online since the current implementation is optimized for UTF16. I've been prototyping this recently and have made decent progress. |
So should I wait for @GrabYourPitchforks' progress (do you have any rough timelline on that?), then overhaul the whole encoders-class or start implementing this proposed change and overhaul it later on? |
No don’t wait for that. This is something we’d want for 2.1. At a very minimum we want to be able to pass a Span<byte> in and get back a string |
OK -- I'll start with. |
While implementing some questions arose: API additionsAdditions to the current API would be: public static byte[] Base64UrlDecode(ReadOnlySpan<char> input);
public static int Base64UrlDecode(ReadOnlySpan<char> input, Span<byte> output); // returns bytes written
public static string Base64UrlEncode(ReadOnlySpan<byte> input);
public static int Base64UrlEncode(ReadOnlySpan<byte> input, Span<char> output); // returns chars written
#if NETCOREAPP2_1 // UTF-8 variants
public static OperationStatus Base64UrlDecode(ReadOnlySpan<byte> utf8, Span<byte> output, out int bytesConsumed, out int bytesWritten, bool isFinalBlock = true);
public static OperationStatus Base64UrlEncode(ReadOnlySpan<byte> input, Span<byte> utf8, out int bytesConsumed, out int bytesWritten, bool isFinalBlock = true);
#endif Are these OK?
String.CreateEdit: it's quite trivial to compute the number of padding-chars, so no problem.
|
@gfoidl Sorry, I should've clarified earlier. The WebEncoders (HTML, JavaScript, etc.) need to be overhauled when UTF-8 support comes online, and those are the only ones I've looked at in detail. Other encoders like base64url encoding are up for grabs as far as I know. |
@davidfowl I just noticed the "up for grabs" label. I've started working on this, just some perf tweaks needs to be done. Hopefully I can submit a PR within the next two days. Can you assign me this issue? |
…master [automated] Merge branch 'release/2.2' => 'master'
@gfoidl only members of the repo can be assigned, but if you're still interested in submitting a PR we'd welcome it! |
Here is the previous attempt #338 I do really want at least part of this in so we can get rid of an allocation in SignalR 😄 |
Tell which part you want, then I can submit a (new) PR. Also if you want to have it simd-based or pure scalar code. |
I want Here is the affected code |
I'll have a look and submit a PR. |
I took a look 😉 -> dotnet/aspnetcore#11047 |
Appears to have been done. |
We should add span overloads to the WebEncoders class, and also use the Base64Encoder/Decoder classes from CoreFX
https://github.com/dotnet/corefx/blob/master/src/System.Memory/src/System/Buffers/Text/Base64Encoder.cs
The text was updated successfully, but these errors were encountered: