-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Use List.ConvertAll
instead of LINQ
#15140
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 8000 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
Conversation
Do we have performance results before and after for this? cc @daxian-dbw |
@TravisEz13 In general, there's not a large performance difference between the two approaches. Using private List<int> list = Enumerable.Repeat(10, 10).ToList();
public List<string> Linq()
{
return list.Select(t => t.ToString()).ToList();
}
public List<string> ConvertAll()
{
return list.ConvertAll(t => t.ToString());
} https://gist.github.com/xtqqczze/22cfeb3eb34e4ca21f4af87adf4956a5
|
Format working group can you review the change? |
I wonder why do you fix only one place? I found some more with |
The analyzer I used only found 1 instance of the pattern: All the other locations seem to be |
Ok :-) |
|
It seems it does not cover array. |
This pull request has been automatically marked as Review Needed because it has been there has not been any activity for 7 days. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Maintainers reviewed and agreed to merge this. |
🎉 Handy links: |
PR Summary
PR Context
https://docs.microsoft.com/dotnet/api/system.collections.generic.list-1.convertall
PR Checklist
.h
,.cpp
,.cs
,.ps1
and.psm1
files have the correct copyright headerWIP:
or[ WIP ]
to the beginning of the title (theWIP
bot will keep its status check atPending
while the prefix is present) and remove the prefix when the PR is ready.(which runs in a different PS Host).