Skip to content

Remove redundant copy of BuildRequestData.TargetNames#7252

Merged
Forgind merged 2 commits into
dotnet:mainfrom
dfederm:remove-redundant-targetnames-copy
Jan 11, 2022
Merged

Remove redundant copy of BuildRequestData.TargetNames#7252
Forgind merged 2 commits into
dotnet:mainfrom
dfederm:remove-redundant-targetnames-copy

Conversation

@dfederm

@dfederm dfederm commented Jan 11, 2022

Copy link
Copy Markdown
Contributor

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<>.

@Forgind Forgind left a comment

Copy link
Copy Markdown
Contributor

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

dfederm commented Jan 11, 2022

Copy link
Copy Markdown
Contributor Author

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