Elide bounds check for MethodToString (#7887)

This commit is contained in:
Ben Adams 2019-03-05 00:44:21 +00:00 committed by Pavel Krymets
parent b9fda976c0
commit 19b52bdc8b
1 changed files with 4 additions and 3 deletions

View File

@ -410,10 +410,11 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure
}
public static string MethodToString(HttpMethod method)
{
int methodIndex = (int)method;
if (methodIndex >= 0 && methodIndex <= 8)
var methodIndex = (int)method;
var methodNames = _methodNames;
if ((uint)methodIndex < (uint)methodNames.Length)
{
return _methodNames[methodIndex];
return methodNames[methodIndex];
}
return null;
}