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
Removed StringBuilder
allocation from Base64Encoding
#5051
Removed StringBuilder
allocation from Base64Encoding
#5051
Conversation
|
||
public static string Base64Encode(this long value, string prefix) | ||
{ | ||
Span<char> sb = stackalloc char[11 + prefix?.Length ?? 0]; |
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.
Testing program is here:
https://gist.github.com/Aaronontheweb/449d565754d5f9bce475653842317277
11
is the number of characters it takes to represent long.MaxValue
in base64 encoded strings
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.
Just a couple little things.
|
||
/// <summary> | ||
/// TBD | ||
/// </summary> | ||
/// <param name="value">TBD</param> | ||
/// <param name="sb">TBD</param> | ||
/// <returns>TBD</returns> | ||
[Obsolete("Do not use. Pass in prefix as a string instead.")] |
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.
Should we change this comment, since our method that takes string is internal now?
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.
Still useful since this method really shouldn't have been exposed as public
anyway, IMHO
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.
We had a bad habit in the very early days of Akka.NET making a lot of the internals public "in case someone wanted to play with them!" and we've been gradually undoing that in our minor version releases....
do | ||
{ | ||
var index = (int)(next & 63); | ||
sb[spanIndex++] = Base64Chars[index]; |
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.
I wonder, is there any advantage at this point to changing Base64Chars to ReadOnlyMemory
?
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.
I don't think so since it's basically just integer accessors
Before (ActorSelection + Ask)
After (ActorSelection + Ask)