Skip to content

Commit 5ff2910

Browse files
benaadamsanalogrelay
authored andcommitted
UriHelper use Ordinal string.IndexOf (#9537)
1 parent a6fd8da commit 5ff2910

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

src/Http/Http.Extensions/src/UriHelper.cs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ namespace Microsoft.AspNetCore.Http.Extensions
1111
/// </summary>
1212
public static class UriHelper
1313
{
14-
private const string ForwardSlash = "/";
15-
private const string Pound = "#";
16-
private const string QuestionMark = "?";
14+
private const char ForwardSlash = '/';
15+
private const char Hash = '#';
16+
private const char QuestionMark = '?';
1717
private const string SchemeDelimiter = "://";
1818

1919
/// <summary>
@@ -103,7 +103,7 @@ public static void FromAbsolute(
103103
path = new PathString();
104104
query = new QueryString();
105105
fragment = new FragmentString();
106-
var startIndex = uri.IndexOf(SchemeDelimiter);
106+
var startIndex = uri.IndexOf(SchemeDelimiter, StringComparison.Ordinal);
107107

108108
if (startIndex < 0)
109109
{
@@ -115,10 +115,9 @@ public static void FromAbsolute(
115115
// PERF: Calculate the end of the scheme for next IndexOf
116116
startIndex += SchemeDelimiter.Length;
117117

118-
var searchIndex = -1;
118+
int searchIndex;
119119
var limit = uri.Length;
120-
121-
if ((searchIndex = uri.IndexOf(Pound, startIndex)) >= 0 && searchIndex < limit)
120+
if ((searchIndex = uri.IndexOf(Hash, startIndex)) >= 0 && searchIndex < limit)
122121
{
123122
fragment = FragmentString.FromUriComponent(uri.Substring(searchIndex));
124123
limit = searchIndex;

0 commit comments

Comments
 (0)