Skip to content

Commit 12620b3

Browse files
Add feedback optimizations
1 parent 4f8faed commit 12620b3

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/libraries/System.Web.HttpUtility/src/System/Web/Util/HttpEncoder.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ internal static void HtmlEncode(string? value, TextWriter output)
129129
private static int IndexOfHtmlAttributeEncodingChars(string s) =>
130130
s.AsSpan().IndexOfAny("<\"'&");
131131

132-
private static bool IsNonAsciiOrSpaceByte(byte b) => b >= 0x7F || b <= 0x20;
132+
private static bool IsNonAsciiOrSpaceByte(byte b) => (uint)b - 0x20 - 1 >= 0x7F - 0x20 - 1;
133133

134134
internal static string JavaScriptStringEncode(string? value)
135135
{
@@ -565,7 +565,7 @@ private static string UrlPathEncodeImpl(string value)
565565
}
566566

567567
int indexOfQuery = value.IndexOf('?');
568-
if (indexOfQuery >= 0 && indexOfQuery < i)
568+
if ((uint)indexOfQuery < (uint)i)
569569
{
570570
// Everything before the Query is valid ASCII
571571
return value;

src/libraries/System.Web.HttpUtility/src/System/Web/Util/UriUtil.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ internal static bool TrySplitUriForPathEncode(string input, out ReadOnlySpan<cha
4040
// To retain the same string as originally given, find the authority in the original url and include
4141
// everything up to that.
4242
int authorityIndex = inputWithoutQueryFragment.IndexOf(authority, StringComparison.OrdinalIgnoreCase);
43-
if (authorityIndex != -1)
43+
if (authorityIndex >= 0)
4444
{
4545
int schemeAndAuthorityLength = authorityIndex + authority.Length;
4646
schemeAndAuthority = input.AsSpan(0, schemeAndAuthorityLength);

0 commit comments

Comments
 (0)