Avoid two unnecessary string.Substring calls in PunycodeDecode (dotnet/coreclr#18546)
authorStephen Toub <stoub@microsoft.com>
Tue, 19 Jun 2018 21:28:32 +0000 (17:28 -0400)
committerGitHub <noreply@github.com>
Tue, 19 Jun 2018 21:28:32 +0000 (17:28 -0400)
Commit migrated from https://github.com/dotnet/coreclr/commit/90850134cb27a499a2bf8e6a545f58ae057ded41

src/libraries/System.Private.CoreLib/src/System/Globalization/IdnMapping.cs

index 6da6f79..8c9c2de 100644 (file)
@@ -638,10 +638,10 @@ namespace System.Globalization
 
                 // See if this section's ASCII or ACE
                 if (ascii.Length < c_strAcePrefix.Length + iAfterLastDot || 
-                    !ascii.Substring(iAfterLastDot,c_strAcePrefix.Length).Equals(c_strAcePrefix, StringComparison.OrdinalIgnoreCase))
+                    string.Compare(ascii, iAfterLastDot, c_strAcePrefix, 0, c_strAcePrefix.Length, StringComparison.OrdinalIgnoreCase) != 0)
                 {
                     // Its ASCII, copy it
-                    output.Append(ascii.Substring(iAfterLastDot, iNextDot - iAfterLastDot));
+                    output.Append(ascii, iAfterLastDot, iNextDot - iAfterLastDot);
                 }
                 else
                 {