-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Why we use CompareInfo.Invariant for Ordinal? #27738
Comments
This is duplicate of https://github.com/dotnet/coreclr/issues/19672. The |
@jkotas Is your link correct? |
It is correct now.
The linked issue is for |
Why the fix is not replicated to CoreFX? https://github.com/dotnet/corefx/blob/master/src/Common/src/CoreLib/System/String.Searching.cs#L55 I am not ready to submit PRs but I will. |
@Anipik The recent change in String.Searching.cs was not mirrored correctly to corefx. Could you please take a look? |
@jkotas there is no missing commit for this change. we will have to manually open the PR to correct it. |
That would be great. Could you please do that? |
yeah i am on it |
I am not so familiar with unicode in-depth and I am amazed to see that
public int IndexOf(char value, StringComparison comparisonType)
and all
IndexOf
overloads for strings likepublic int IndexOf(string value, int startIndex, int count, StringComparison comparisonType)
call CompareInfo.Invariant.IndexOf() for both InvariantCulture (InvariantCultureIgnoreCase) and Ordinal (OrdinalIgnoreCase).
In the same time we have
IndexOf
overloads for chars which use really ordinal comparison from SpanHelpers with SIMD accelerations.public int IndexOf(char value) => SpanHelpers.IndexOf(ref _firstChar, value, Length);
We even have [
public static int CompareOrdinal(string strA, int indexA, string strB, int indexB, int length)
}(https://source.dot.net/#System.Private.CoreLib/shared/System/String.Comparison.cs,341906879aa2feb9).(internally SpanHelpers with SIMD accelerations.)
I'd expect the same for strings too if StringComparison is Ordinal or OrdinalIgnoreCase.
In the case we could implement very fast SIMD accelerated methods like IndexOf(), LastIndexOf(), Replace() and perhaps some more.
For OrdinalIgnoreCase we could implement unicode simple case folding (#17233). With this enhancement we could to get great wins in RegEx (see Rust RegEx lib) and simplify Boyer-Moore implementation (which is also useful in IndexOf() and Replace() - #20674 and https://github.com/dotnet/coreclr/issues/6918).
Some languages (like PowerShell) could get great wins in identifier comparisons.
The text was updated successfully, but these errors were encountered: