-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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
Faster Clone() in kv/key.go #11957
Faster Clone() in kv/key.go #11957
Conversation
A simple benchmark for this change: DeepCopyBytes is the new one, test value is []byte("11111") |
Codecov Report
@@ Coverage Diff @@
## master #11957 +/- ##
================================================
- Coverage 81.6088% 81.2264% -0.3824%
================================================
Files 449 443 -6
Lines 96916 94921 -1995
================================================
- Hits 79092 77101 -1991
- Misses 12252 12334 +82
+ Partials 5572 5486 -86 |
@ZYunH Thanks for your contributing, please follow the Commit Message and Pull Request Style to reformat the PR title. |
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.
LGTM
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.
LGTM
/run-all-tests |
The new function use a predefined byte slice with length len(k) instead of use an undefined []byte(nil). The latter will grow in copy procession, and since Key is just an alias for []byte, so we can use len(k) instead of len([]byte(k)), the former is more readable.