summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephen Toub <stoub@microsoft.com>2017-10-09 21:45:48 -0400
committerGitHub <noreply@github.com>2017-10-09 21:45:48 -0400
commit8ec9b34df095df032e37b4c20a7359e9df7ae0ce (patch)
tree3e91f9443f09e50047296f815ea39317cb694b72
parent171c9c25ef815b88fe0656a48042b275c7d61d6d (diff)
parentdccf52a75e935276075d2aee1d1ec1338b84855c (diff)
downloadcoreclr-8ec9b34df095df032e37b4c20a7359e9df7ae0ce.tar.gz
coreclr-8ec9b34df095df032e37b4c20a7359e9df7ae0ce.tar.bz2
coreclr-8ec9b34df095df032e37b4c20a7359e9df7ae0ce.zip
Merge pull request #14394 from stephentoub/undo_strcomp
Undo unnecessary change from DateTime.Parse commit
-rw-r--r--src/mscorlib/src/System/String.Comparison.cs14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/mscorlib/src/System/String.Comparison.cs b/src/mscorlib/src/System/String.Comparison.cs
index 8e628d92ec..fd318b3d08 100644
--- a/src/mscorlib/src/System/String.Comparison.cs
+++ b/src/mscorlib/src/System/String.Comparison.cs
@@ -219,12 +219,20 @@ namespace System
}
}
- private unsafe static int CompareOrdinalHelper(string strA, string strB)
+ private static unsafe int CompareOrdinalHelper(String strA, String strB)
{
+ Debug.Assert(strA != null);
+ Debug.Assert(strB != null);
+
+ // NOTE: This may be subject to change if eliminating the check
+ // in the callers makes them small enough to be inlined
+ Debug.Assert(strA._firstChar == strB._firstChar,
+ "For performance reasons, callers of this method should " +
+ "check/short-circuit beforehand if the first char is the same.");
+
int length = Math.Min(strA.Length, strB.Length);
- fixed (char* ap = strA)
- fixed (char* bp = strB)
+ fixed (char* ap = &strA._firstChar) fixed (char* bp = &strB._firstChar)
{
char* a = ap;
char* b = bp;