Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/mscorlib/shared/System/Globalization/CompareInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,7 @@ internal static unsafe int CompareOrdinalIgnoreCase(ReadOnlySpan<char> strA, Rea
char* b = bp;

// in InvariantMode we support all range and not only the ascii characters.
char maxChar = (char) (GlobalizationMode.Invariant ? 0xFFFF : 0x80);
char maxChar = (char) (GlobalizationMode.Invariant ? 0xFFFF : 0x7F);
Copy link
Member

@danmoseley danmoseley Feb 24, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this be computed just once in a static ctor? It's cheap, but this code is called a lot. (I can't see the context right now so this may be off.)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@benaadams, thoughts?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jkotas pointed out it already is #16535 (comment)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was referring to the value, not GlobalizationMode. Ie put either 0xFFFF or 0x7F in a readonly static field. But seems unlikely that would be any faster than a conditional check each time here.


while (length != 0 && (*a <= maxChar) && (*b <= maxChar))
{
Expand Down
2 changes: 1 addition & 1 deletion src/mscorlib/src/System/String.Comparison.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ private unsafe static int CompareOrdinalIgnoreCaseHelper(String strA, String str
[MethodImplAttribute(MethodImplOptions.InternalCall)]
internal static extern int CompareOrdinalHelper(String strA, int indexA, int countA, String strB, int indexB, int countB);

//This will not work in case-insensitive mode for any character greater than 0x80.
//This will not work in case-insensitive mode for any character greater than 0x7F.
//We'll throw an ArgumentException.
[MethodImplAttribute(MethodImplOptions.InternalCall)]
unsafe internal static extern int nativeCompareOrdinalIgnoreCaseWC(String strA, sbyte* strBBytes);
Expand Down