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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
More Efficient ToBase64String #1153
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1153 +/- ##
==========================================
- Coverage 82.29% 82.23% -0.06%
==========================================
Files 680 680
Lines 29301 29301
Branches 3279 3279
==========================================
- Hits 24112 24096 -16
- Misses 4500 4516 +16
Partials 689 689
Continue to review full report at Codecov.
|
src/ImageSharp/ImageExtensions.cs
Outdated
buffer.AsSpan().CopyTo(sharedBuffer); | ||
return $"data:{format.DefaultMimeType};base64,{Convert.ToBase64String(sharedBuffer)}"; |
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.
Is there a reason to operate on a copy instead of ArraySegment<byte>.Array
?
ToBase64String(array, offset, length)
seems to be available on all platforms. I don't even think we need the BASE64SPAN
define.
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.
Haha yes, much better. Will update.
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.
Looks good now!
Prerequisites
Description
Prevents allocation of an array when saving to a Base64 encoded string.