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

Use capacity hint in concat #2288

Merged
merged 1 commit into from
Aug 14, 2023
Merged

Use capacity hint in concat #2288

merged 1 commit into from
Aug 14, 2023

Conversation

DrJosh9000
Copy link
Contributor

I assume this is what @moskyb intended to do here... but didn't.

(I, too, like to make values and never use them.)

@DrJosh9000 DrJosh9000 requested a review from a team August 14, 2023 05:56
@@ -511,7 +512,7 @@ func concat[T any](a ...[]T) []T {
cap += len(s)
}

var result []T
result := make([]T, 0, cap)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So the += prevented the compiler from deteecting this. Good to know!

@DrJosh9000 DrJosh9000 merged commit 7b8ee9d into main Aug 14, 2023
@DrJosh9000 DrJosh9000 deleted the use-capacity-hint branch August 14, 2023 06:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants