UriHelper use Ordinal string.IndexOf (#9537)
This commit is contained in:
parent
a6fd8da9e8
commit
5ff2910d09
|
|
@ -11,9 +11,9 @@ namespace Microsoft.AspNetCore.Http.Extensions
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static class UriHelper
|
public static class UriHelper
|
||||||
{
|
{
|
||||||
private const string ForwardSlash = "/";
|
private const char ForwardSlash = '/';
|
||||||
private const string Pound = "#";
|
private const char Hash = '#';
|
||||||
private const string QuestionMark = "?";
|
private const char QuestionMark = '?';
|
||||||
private const string SchemeDelimiter = "://";
|
private const string SchemeDelimiter = "://";
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -103,7 +103,7 @@ namespace Microsoft.AspNetCore.Http.Extensions
|
||||||
path = new PathString();
|
path = new PathString();
|
||||||
query = new QueryString();
|
query = new QueryString();
|
||||||
fragment = new FragmentString();
|
fragment = new FragmentString();
|
||||||
var startIndex = uri.IndexOf(SchemeDelimiter);
|
var startIndex = uri.IndexOf(SchemeDelimiter, StringComparison.Ordinal);
|
||||||
|
|
||||||
if (startIndex < 0)
|
if (startIndex < 0)
|
||||||
{
|
{
|
||||||
|
|
@ -115,10 +115,9 @@ namespace Microsoft.AspNetCore.Http.Extensions
|
||||||
// PERF: Calculate the end of the scheme for next IndexOf
|
// PERF: Calculate the end of the scheme for next IndexOf
|
||||||
startIndex += SchemeDelimiter.Length;
|
startIndex += SchemeDelimiter.Length;
|
||||||
|
|
||||||
var searchIndex = -1;
|
int searchIndex;
|
||||||
var limit = uri.Length;
|
var limit = uri.Length;
|
||||||
|
if ((searchIndex = uri.IndexOf(Hash, startIndex)) >= 0 && searchIndex < limit)
|
||||||
if ((searchIndex = uri.IndexOf(Pound, startIndex)) >= 0 && searchIndex < limit)
|
|
||||||
{
|
{
|
||||||
fragment = FragmentString.FromUriComponent(uri.Substring(searchIndex));
|
fragment = FragmentString.FromUriComponent(uri.Substring(searchIndex));
|
||||||
limit = searchIndex;
|
limit = searchIndex;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue