Skip to content

Commit f136b66

Browse files
authored
Apply AppendEnfOfLine perf suggestion
1 parent 60d22c0 commit f136b66

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -308,16 +308,16 @@ public bool ParseHeaders(TRequestHandler handler, ref SequenceReader<byte> reade
308308

309309
private static byte[] AppendEndOfLine(ReadOnlySpan<byte> span, bool lineFeedOnly)
310310
{
311+
Debug.Assert(!span.IsEmpty);
312+
311313
var array = new byte[span.Length + (lineFeedOnly ? 1 : 2)];
312314

313-
span.CopyTo(array);
314-
array[^1] = ByteLF;
315+
Debug.Assert(array.Length >= 2);
315316

316-
if (!lineFeedOnly)
317-
{
318-
array[^2] = ByteCR;
319-
}
317+
array[^2] = ByteCR;
318+
array[^1] = ByteLF;
320319

320+
span.CopyTo(array);
321321
return array;
322322
}
323323

0 commit comments

Comments
 (0)