Only allocate key string when unknown

This commit is contained in:
Ben Adams 2016-07-22 12:29:28 +01:00
parent 27f8c8dca2
commit 7c811ff568
2 changed files with 4 additions and 2 deletions

View File

@ -4197,7 +4197,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
public unsafe void Append(byte[] keyBytes, int keyOffset, int keyLength, string value)
{
var key = new string('\0', keyLength);
string key;
fixed (byte* ptr = &keyBytes[keyOffset])
{
var pUB = ptr;
@ -4899,6 +4899,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
break;
}
key = new string('\0', keyLength);
fixed(char *keyBuffer = key)
{
if (!AsciiUtilities.TryGetAsciiString(ptr, keyBuffer, keyLength))

View File

@ -417,7 +417,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
{(loop.ClassName == "FrameRequestHeaders" ? $@"
public unsafe void Append(byte[] keyBytes, int keyOffset, int keyLength, string value)
{{
var key = new string('\0', keyLength);
string key;
fixed (byte* ptr = &keyBytes[keyOffset])
{{
var pUB = ptr;
@ -446,6 +446,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
break;
")}}}
key = new string('\0', keyLength);
fixed(char *keyBuffer = key)
{{
if (!AsciiUtilities.TryGetAsciiString(ptr, keyBuffer, keyLength))