-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
bug: fix slice init length #16674
bug: fix slice init length #16674
Conversation
Signed-off-by: cuishuang <[email protected]>
Review ChecklistHello reviewers! 👋 Please follow this checklist when reviewing this Pull Request. General
Tests
Documentation
New flags
If a workflow is added or modified:
Backward compatibility
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #16674 +/- ##
==========================================
- Coverage 68.92% 68.91% -0.01%
==========================================
Files 1562 1562
Lines 200941 200941
==========================================
- Hits 138497 138481 -16
- Misses 62444 62460 +16 ☔ View full report in Codecov by Sentry. |
@@ -189,7 +189,7 @@ func StartTracing(serviceName string) io.Closer { | |||
} | |||
|
|||
func fail(serviceName string) io.Closer { | |||
options := make([]string, len(tracingBackendFactories)) | |||
options := make([]string, 0, len(tracingBackendFactories)) |
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.
This is a good catch. The bug is that we are allocating a slice with empty strings and then appending to it, so we end up with a slice that is twice as long as it really needs to be. Another way of fixing it would have been to set the already allocated elements instead of appending to the slice, but this is cleaner.
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.
Thanks, @cuishuang !
My pleasure. |
Description
fix slice init length
Related Issue(s)
Checklist
Deployment Notes