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

Remove most usage of "new ArrayBuilder" #74689

Merged
merged 1 commit into from
Aug 9, 2024

Conversation

ToddGrun
Copy link
Contributor

@ToddGrun ToddGrun commented Aug 8, 2024

Most callers of this were intending to instead use ArrayBuilder.GetInstance (as that actually is what pulls items from the pool). Otherwise, the code would create a new ArrayBuilder (and consequently the ImmutableArray.Builder), reallocate until the array hit the appropriate size, and likely return the item to a pool that would never be pulled from.

Most callers of this were intending to instead use ArrayBuilder.GetInstance (as that actually is what pulls items from the pool). Otherwise, the code would create a new ArrayBuilder (and consequently the ImmutableArray.Builder), reallocate until the array hit the appropriate size, and likely return the item to a pool that would never be pulled from.
@ToddGrun ToddGrun requested review from a team as code owners August 8, 2024 21:38
@dotnet-issue-labeler dotnet-issue-labeler bot added Area-Infrastructure untriaged Issues and PRs which have not yet been triaged by a lead labels Aug 8, 2024
@ToddGrun
Copy link
Contributor Author

ToddGrun commented Aug 8, 2024

Note, I didn't touch the compilers folder, but I'm guessing they have a fair number of mis-uses also.

@JoeRobich
Copy link
Member

Can we ban the use of the ArrayBuilder constructor?

@ToddGrun
Copy link
Contributor Author

ToddGrun commented Aug 8, 2024

Can we ban the use of the ArrayBuilder constructor?

I thought about that, but there are legitimate uses of this when creating pools of ArrayBuilders. Hopefully, most of these came from copy/paste mistakes, and now there shouldn't be much code using that form to copy (outside of the compilers folder)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Infrastructure untriaged Issues and PRs which have not yet been triaged by a lead VSCode
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants