Skip to content

Commit e6d7dde

Browse files
committed
Elide bounds check for MethodToString
1 parent 9cb1185 commit e6d7dde

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/Servers/Kestrel/Core/src/Internal/Infrastructure/HttpUtilities.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -410,10 +410,11 @@ public static string VersionToString(HttpVersion httpVersion)
410410
}
411411
public static string MethodToString(HttpMethod method)
412412
{
413-
int methodIndex = (int)method;
414-
if (methodIndex >= 0 && methodIndex <= 8)
413+
var methodIndex = (int)method;
414+
var methodNames = _methodNames;
415+
if ((uint)methodIndex < (uint)methodNames.Length)
415416
{
416-
return _methodNames[methodIndex];
417+
return methodNames[methodIndex];
417418
}
418419
return null;
419420
}

0 commit comments

Comments
 (0)