Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve HTTP/2 scaling performance #35694

Merged
merged 11 commits into from
May 7, 2020
Prev Previous commit
Next Next commit
Avoid dictionary lookup in HttpMethod.Normalize
  • Loading branch information
stephentoub committed May 7, 2020
commit 15bc42d5077061119b4dbae130820eab8f6013c8
Original file line number Diff line number Diff line change
@@ -176,9 +176,12 @@ public override string ToString()
/// </summary>
internal static HttpMethod Normalize(HttpMethod method)
{
// _http3EncodedBytes is only set for the singleton instances, so if it's not null,
// we can avoid the dictionary lookup. Otherwise, look up the method instance in the
// dictionary and return the normalized instance if it's found.
Debug.Assert(method != null);
return s_knownMethods.TryGetValue(method, out HttpMethod? normalized) ?
normalized :
return
method._http3EncodedBytes is null && s_knownMethods.TryGetValue(method, out HttpMethod? normalized) ? normalized :
method;
}