summaryrefslogtreecommitdiff
path: root/src/mscorlib
diff options
context:
space:
mode:
authorStephen Toub <stoub@microsoft.com>2017-09-08 10:05:22 -0400
committerStephen Toub <stoub@microsoft.com>2017-10-06 08:27:41 -0400
commit89a825e4a74445bdf29b9114a209ed45f16ddc79 (patch)
tree0c74e32aed58f18cb2dd97761c42ff6d548abfa5 /src/mscorlib
parent99fa77856e5c871e9feaa94e16badd23df7217f3 (diff)
downloadcoreclr-89a825e4a74445bdf29b9114a209ed45f16ddc79.tar.gz
coreclr-89a825e4a74445bdf29b9114a209ed45f16ddc79.tar.bz2
coreclr-89a825e4a74445bdf29b9114a209ed45f16ddc79.zip
Avoid slicing/extra method call while tokenizing in common case
Diffstat (limited to 'src/mscorlib')
-rw-r--r--src/mscorlib/shared/System/Globalization/DateTimeFormatInfo.cs16
1 files changed, 4 insertions, 12 deletions
diff --git a/src/mscorlib/shared/System/Globalization/DateTimeFormatInfo.cs b/src/mscorlib/shared/System/Globalization/DateTimeFormatInfo.cs
index e27333a172..4a8059f50d 100644
--- a/src/mscorlib/shared/System/Globalization/DateTimeFormatInfo.cs
+++ b/src/mscorlib/shared/System/Globalization/DateTimeFormatInfo.cs
@@ -2813,7 +2813,10 @@ namespace System.Globalization
compareStrings = !(Char.IsLetter(nextCh));
}
}
- if (compareStrings && CompareStringIgnoreCaseOptimized(str.Value.Slice(str.Index, value.tokenString.Length), value.tokenString.AsReadOnlySpan()))
+
+ if (compareStrings &&
+ ((value.tokenString.Length == 1 && str.Value[str.Index] == value.tokenString[0]) ||
+ Culture.CompareInfo.Compare(str.Value.Slice(str.Index, value.tokenString.Length), value.tokenString.AsReadOnlySpan(), CompareOptions.IgnoreCase) == 0))
{
tokenType = value.tokenType & TokenMask;
tokenValue = value.tokenValue;
@@ -2974,17 +2977,6 @@ namespace System.Globalization
return (this.Culture.CompareInfo.Compare(string1, offset1, length1, string2, offset2, length2, CompareOptions.IgnoreCase) == 0);
}
- private bool CompareStringIgnoreCaseOptimized(ReadOnlySpan<char> string1, ReadOnlySpan<char> string2)
- {
- // Optimize for one character cases which are common due to date and time separators (/ and :)
- if (string1.Length == 1 && string2.Length == 1 && string1[0] == string2[0])
- {
- return true;
- }
-
- return (this.Culture.CompareInfo.Compare(string1, string2, CompareOptions.IgnoreCase) == 0);
- }
-
// class DateTimeFormatInfo
internal class TokenHashValue