Skip to content

Commit 108529f

Browse files
committed
Remove gotos
1 parent 58d2231 commit 108529f

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

src/Servers/Kestrel/Core/src/Internal/Http/HttpParser.cs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -378,20 +378,20 @@ private static bool TryTakeSingleHeader(TRequestHandler handler, ReadOnlySpan<by
378378
if ((uint)nameEnd >= (uint)headerLine.Length)
379379
{
380380
// Colon not found.
381-
goto Reject;
381+
return false;
382382
}
383383

384384
// Early memory read to hide latency
385385
var expectedColon = headerLine[nameEnd];
386386
if (nameEnd == 0)
387387
{
388388
// Header name is empty.
389-
goto Reject;
389+
return false;
390390
}
391391
if (expectedColon != ByteColon)
392392
{
393393
// Header name space or tab.
394-
goto Reject;
394+
return false;
395395
}
396396

397397
// Skip colon to get to the value start.
@@ -457,11 +457,6 @@ private static bool TryTakeSingleHeader(TRequestHandler handler, ReadOnlySpan<by
457457
handler.OnHeader(name: headerLine[..nameEnd], value: headerLine[valueStart..valueEnd]);
458458

459459
return true;
460-
461-
Reject:
462-
// Reject is a conditional jump forward as we expect most headers to be accepted,
463-
// so we want it to be unpredicted by an unprimied branch predictor.
464-
return false;
465460
}
466461

467462
[MethodImpl(MethodImplOptions.NoInlining)]

0 commit comments

Comments
 (0)