Skip to content

Commit bacf760

Browse files
committed
Performance improvements
This adds additional performance improvements (namely string.Concat overloads) on top of #411.
1 parent 7e57363 commit bacf760

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

src/Microsoft.AspNet.Http.Abstractions/FragmentString.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ public static FragmentString FromUriComponent(Uri uri)
100100
string fragmentValue = uri.GetComponents(UriComponents.Fragment, UriFormat.UriEscaped);
101101
if (!string.IsNullOrEmpty(fragmentValue))
102102
{
103-
fragmentValue = $"#{fragmentValue}";
103+
fragmentValue = "#" + fragmentValue;
104104
}
105105
return new FragmentString(fragmentValue);
106106
}

src/Microsoft.AspNet.Http.Extensions/UriHelper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public static string Encode(
2525
FragmentString fragment = new FragmentString())
2626
{
2727
string combinePath = (pathBase.HasValue || path.HasValue) ? (pathBase + path).ToString() : "/";
28-
return $"{combinePath}{query.ToString()}{fragment.ToString()}";
28+
return combinePath + query.ToString() + fragment.ToString();
2929
}
3030

3131
/// <summary>

src/Microsoft.AspNet.Http/ResponseCookies.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public void Append(string key, string value, CookieOptions options)
8080
/// <param name="key"></param>
8181
public void Delete(string key)
8282
{
83-
var encodedKeyPlusEquals = $"{UrlEncoder.Default.Encode(key)}=";
83+
var encodedKeyPlusEquals = UrlEncoder.Default.Encode(key) + "=";
8484
Func<string, string, bool> predicate = (value, encKeyPlusEquals) => value.StartsWith(encKeyPlusEquals, StringComparison.OrdinalIgnoreCase);
8585

8686
StringValues deleteCookies = $"{encodedKeyPlusEquals}; expires=Thu, 01-Jan-1970 00:00:00 GMT";
@@ -124,7 +124,7 @@ public void Delete(string key, CookieOptions options)
124124
throw new ArgumentNullException(nameof(options));
125125
}
126126

127-
var encodedKeyPlusEquals = $"{UrlEncoder.Default.Encode(key)}=";
127+
var encodedKeyPlusEquals = UrlEncoder.Default.Encode(key) + "=";
128128
bool domainHasValue = !string.IsNullOrEmpty(options.Domain);
129129
bool pathHasValue = !string.IsNullOrEmpty(options.Path);
130130

src/Microsoft.AspNet.WebUtilities/QueryHelpers.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ private static string AddQueryString(
105105
/// <summary>
106106
/// Parse a query string into its component key and value parts.
107107
/// </summary>
108-
/// <param name="text">The raw query string value, with or without the leading '?'.</param>
108+
/// <param name="queryString">The raw query string value, with or without the leading '?'.</param>
109109
/// <returns>A collection of parsed keys and values.</returns>
110110
public static Dictionary<string, StringValues> ParseQuery(string queryString)
111111
{
@@ -123,7 +123,7 @@ public static Dictionary<string, StringValues> ParseQuery(string queryString)
123123
/// <summary>
124124
/// Parse a query string into its component key and value parts.
125125
/// </summary>
126-
/// <param name="text">The raw query string value, with or without the leading '?'.</param>
126+
/// <param name="queryString">The raw query string value, with or without the leading '?'.</param>
127127
/// <returns>A collection of parsed keys and values, null if there are no entries.</returns>
128128
public static Dictionary<string, StringValues> ParseNullableQuery(string queryString)
129129
{
@@ -135,7 +135,7 @@ public static Dictionary<string, StringValues> ParseNullableQuery(string querySt
135135
}
136136

137137
int scanIndex = 0;
138-
if (!string.IsNullOrEmpty(queryString) && queryString[0] == '?')
138+
if (queryString[0] == '?')
139139
{
140140
scanIndex = 1;
141141
}

0 commit comments

Comments
 (0)