-
Notifications
You must be signed in to change notification settings - Fork 693
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
Use string.Contains instead of IEnumerable.Contains #5551
Conversation
@@ -204,7 +204,7 @@ public static bool TryParse(string value, bool allowFloating, [NotNullWhen(true) | |||
#if NETCOREAPP2_1_OR_GREATER | |||
if (allowFloating && minVersionString.Contains('*', StringComparison.Ordinal)) |
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.
Does this have the same problem?
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.
Additional overloads for string.Contains
were added in 2.1+, so this call doesn't have the same issue.
@Erarndt I think we'd probably want more granular issues here, since there's some changes that aren't related to what the main issue is claiming. |
Sure, I defer to you folks on how to organize these. I've found these while investigating the main issue, so I was unsure how you'd like to categorize them. |
This PR has been automatically marked as stale because it has no activity for 7 days. It will be closed if no further activity occurs within another 90 days of this comment. If it is closed, you may reopen it anytime when you're ready again, as long as you don't delete the branch. |
Bug
Fixes: NuGet/Home#13124
Regression? Last working version:
Description
This code was mistakenly using the
Enumerable.Contains()
overload which ends up allocating an enumerator. Usingstring.Contains()
avoids this allocation and is faster. Example benchmark over 100 invocations:PR Checklist
PR has a meaningful title
PR has a linked issue.
Described changes
Tests
Documentation