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 #10504

Closed
alingse opened this issue May 27, 2024 · 2 comments · Fixed by #10528
Closed

miss makezero in slice init #10504

alingse opened this issue May 27, 2024 · 2 comments · Fixed by #10528
Assignees
Labels
imp1 High importance
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/9242977316/job/25426502162

====================================================================================================
append to slice `marshalled` with non-zero initialized length at https://github.com/ledgerwatch/erigon/blob/main/core/blockchain.go#L23[9](https://github.com/alingse/go-linter-runner/actions/runs/9242977316/job/25426502162#step:4:10):16
append to slice `files` with non-zero initialized length at https://github.com/ledgerwatch/erigon/blob/main/diagnostics/logs.go#L76:[11](https://github.com/alingse/go-linter-runner/actions/runs/9242977316/job/25426502162#step:4:12)
append to slice `files` with non-zero initialized length at https://github.com/ledgerwatch/erigon/blob/main/cmd/snapshots/manifest/manifest.go#L292:12
append to slice `files` with non-zero initialized length at https://github.com/ledgerwatch/erigon/blob/main/cmd/snapshots/manifest/manifest.go#L302:[12](https://github.com/alingse/go-linter-runner/actions/runs/9242977316/job/25426502162#step:4:13)
====================================================================================================

the marshalled := make([]map[string]interface{}, len(receipts)) should be marshalled := make([]map[string]interface{}, 0, len(receipts))

and the files := make([]file, len(infos)) should be files := make([]file, 0, len(infos))

@yperbasis
Copy link
Member

@shohamc1 could you take a look please

@awskii
Copy link
Member

awskii commented May 28, 2024

we got some maps pre-allocated and in 8/10 cases allocation used fully, so @shohamc1 keep that in mind

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

Successfully merging a pull request may close this issue.

4 participants