Skip to content
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

miss makezero in slice init #4081

Closed
alingse opened this issue May 27, 2024 · 1 comment · Fixed by #4194
Closed

miss makezero in slice init #4081

alingse opened this issue May 27, 2024 · 1 comment · Fixed by #4194
Assignees
Labels
Milestone

Comments

@alingse
Copy link

alingse commented May 27, 2024

I was running github actions to run linter makezero for top github golang repos.

see issues alingse/go-linter-runner#1

and the github actions output https://github.com/alingse/go-linter-runner/actions/runs/9242979001/job/25426506045

====================================================================================================
append to slice `res` with non-zero initialized length at https://github.com/aquasecurity/tracee/blob/main/pkg/bufferdecoder/eventsreader.go#L384:[9](https://github.com/alingse/go-linter-runner/actions/runs/9242979001/job/25426506045#step:4:10)
====================================================================================================

the res := make([]byte, max) should be res := make([]byte, 0, max)

the origin way is no help to optimize memory allocation, the append still cause an extra allocation

@geyslan
Copy link
Member

geyslan commented May 27, 2024

@alingse thanks for your report. @yanivagman FYI.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants