diff --git a/src/libraries/System.Private.CoreLib/src/System/Net/WebUtility.cs b/src/libraries/System.Private.CoreLib/src/System/Net/WebUtility.cs index 398873d249a506..257b0e1e633cec 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Net/WebUtility.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Net/WebUtility.cs @@ -185,7 +185,7 @@ private static void HtmlEncode(ReadOnlySpan input, ref ValueStringBuilder ReadOnlySpan valueSpan = value.AsSpan(); - int index = IndexOfHtmlDecodingChars(valueSpan); + int index = valueSpan.IndexOf('&'); if (index < 0) { return value; @@ -215,7 +215,7 @@ public static void HtmlDecode(string? value, TextWriter output) ReadOnlySpan valueSpan = value.AsSpan(); - int index = IndexOfHtmlDecodingChars(valueSpan); + int index = valueSpan.IndexOf('&'); if (index == -1) { output.Write(value); @@ -701,21 +701,6 @@ private static bool ValidateUrlEncodingParameters(byte[]? bytes, int offset, int return true; } - private static int IndexOfHtmlDecodingChars(ReadOnlySpan input) - { - // this string requires html decoding if it contains '&' or a surrogate character - for (int i = 0; i < input.Length; i++) - { - char c = input[i]; - if (c == '&' || char.IsSurrogate(c)) - { - return i; - } - } - - return -1; - } - #endregion // Internal struct to facilitate URL decoding -- keeps char buffer and byte buffer, allows appending of either chars or bytes