-
Notifications
You must be signed in to change notification settings - Fork 18k
proposal: slices: Use make instead of Grow
in Concat
#65884
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
Comments
Seeing the comment now - https://go-review.googlesource.com/c/go/+/504882#:~:text=Aug%2007%2C-,2023,-Since%20we%20don%27t |
@justinhwang func BenchmarkSortStrings(b *testing.B) {
s := []string{"heart", "lungs", "brain", "kidneys", "pancreas"}
b.ReportAllocs()
for i := 0; i < b.N; i++ {
sort.Strings(s)
}
} Therefore, I believe that this post is no longer valid. Do you understand why slices.Grow replace builtin make? |
See the discussion on https://go.dev/cl/504882. |
@ianlancetaylor Thank you for your reply. ![]() |
The reason we want to round up to the next size class is to avoid reallocation on a subsequent
With |
@randall77 |
Proposal Details
slices.Concat
unnecessarily usesGrow
instead of make which unnecessarily increases time/opThe text was updated successfully, but these errors were encountered: