Repository navigation
Replace String.CompareOrdinal to string.Equals in KnownTypes - #7500
Merged
Merged
Conversation
Contributor
|
Curious why this is limited to KnownTypes only? A quick search here on Github shows that string.Compare is being used in >36 files. Wouldn't it make sense changing them all at once, so you don't end up with mixed coding styles? |
Member
Author
|
Thank you @Symbai Please don't worry, I will continue to optimize the code. Small changes help code review, and changing too much code at once can lead to conflicts |
Contributor
|
For x86 string equality operator generates a bit more efficient code. |
dipeshmsft
approved these changes
Feb 15, 2023
anjaligupta-dev
approved these changes
Feb 27, 2023
Member
Author
|
Thank you @dipeshmsft And I will update the other files soon @Symbai |
lindexi
added a commit
to dotnet-campus/wpf
that referenced
this pull request
Mar 28, 2023
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
We can use
string.Equals(string1, string2, StringComparison.Ordinal)to check for equality, see https://learn.microsoft.com/en-us/dotnet/csharp/how-to/compare-strings and https://learn.microsoft.com/en-us/dotnet/standard/base-types/best-practices-stringsReference #6588
Cc @Kuldeep-MS
Customer Impact
Small performance improvements
Regression
None.
Testing
Just CI.
Risk
Low.
Microsoft Reviewers: Open in CodeFlow