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 redundant copy of BuildRequestData.TargetNames #7252

Merged
merged 2 commits into from
Jan 11, 2022

Conversation

dfederm
Copy link
Contributor

@dfederm dfederm commented Jan 11, 2022

Minor change to remove an extra defensive copy of an array. A BuildRequestData ctor overload copies it despite the this ctor it calls also copying it.

Also a very minor perf change to use an array and copy via CopyTo instead of cloning with a List<>.

Copy link
Member

@Forgind Forgind left a comment

Choose a reason for hiding this comment

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

Thanks!

Nit: BuildManager_Tests, line 1409 has data.TargetNames.ToArray(); with this change, you should be able to simplify that too.

@dfederm
Copy link
Contributor Author

dfederm commented Jan 11, 2022

BuildManager_Tests, line 1409 has data.TargetNames.ToArray(); with this change, you should be able to simplify that too.

@Forgind BuildRequestData still exposes TargetNames as an ICollection<string>, so the alternative would be a cast, and I think it'd be better not to assume. You did make me realize something important though; ICollection is technically mutable, so changing to an array for the underlying type breaks that. I'll put it back at a List<>

@Forgind Forgind merged commit 7f9429d into dotnet:main Jan 11, 2022
@dfederm dfederm deleted the remove-redundant-targetnames-copy branch July 29, 2022 18:17
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.

3 participants