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
Copy link
Copy Markdown
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
Copy Markdown
Contributor

@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
Copy Markdown
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<>

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