-
Notifications
You must be signed in to change notification settings - Fork 476
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
perf: higher performance unsafeStringToSlice #371
base: develop
Are you sure you want to change the base?
Conversation
Higher performance UnsafeStringToSlice
Benchmark? Comparison? Also the assumption of the structure size which equals to []byte is unacceptable. |
hdr.Cap = len(s) | ||
hdr.Len = len(s) | ||
return b | ||
func unsafeStringToSlice(s string) []byte { |
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.
@dxasu you should remove "reflect" import path also
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.
done
remove unused import reflect
@joway it can be different size for string and stringheader. |
try this code snippet which has better readability if we'd like to sacrifice forward compatibility for the minor optimisation. I won't do that. |
@xiaost
|
@dxasu I know what you said, but I don't know what is your point. |
Higher performance UnsafeStringToSlice
What type of PR is this?
perf
Check the PR title.
(Optional) More detailed description for this PR(en: English/zh: Chinese).
en: higher performance unsafeStringToSlice
(Optional) Which issue(s) this PR fixes:
Fixes #370