From: Stephen Toub Date: Tue, 19 Jun 2018 21:28:32 +0000 (-0400) Subject: Avoid two unnecessary string.Substring calls in PunycodeDecode (dotnet/coreclr#18546) X-Git-Tag: submit/tizen/20210909.063632~11030^2~4563 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f8086fa86ba1b95ebe0923335b4ebe1f7c6f9a3c;p=platform%2Fupstream%2Fdotnet%2Fruntime.git Avoid two unnecessary string.Substring calls in PunycodeDecode (dotnet/coreclr#18546) Commit migrated from https://github.com/dotnet/coreclr/commit/90850134cb27a499a2bf8e6a545f58ae057ded41 --- diff --git a/src/libraries/System.Private.CoreLib/src/System/Globalization/IdnMapping.cs b/src/libraries/System.Private.CoreLib/src/System/Globalization/IdnMapping.cs index 6da6f79..8c9c2de 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Globalization/IdnMapping.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Globalization/IdnMapping.cs @@ -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 {