Skip to content

Commit 19b52bd

Browse files
benaadamspakrym
authored andcommitted
Elide bounds check for MethodToString (#7887)
1 parent b9fda97 commit 19b52bd

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)