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
all: preallocate slices with known size #10716
Conversation
test-me-please |
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.
Can we add this as a checker?
Will look into it, yes. But there are some cases in which preallocation doesn't make sense, i.e. the slice is rather small and/or the capacity cannot be estimated reliably. Thus the
Not sure how to tell the checker to ignore these cases. |
I guess there isn't a tag to ignore false positives. |
Doesn't look like it 😞 |
Found some other cases using the |
d01e76c
to
b25cd23
Compare
test-me-please |
This avoids reallocations in loops, cf. #10056 Found using github.com/alexkohler/prealloc Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
b25cd23
to
04549f6
Compare
test-me-please |
These were missed in #10716 Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
These were missed in #10716 Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
This avoids reallocations in loops, cf. #10056
Found using github.com/alexkohler/prealloc