Only allocate key string when unknown
This commit is contained in:
parent
27f8c8dca2
commit
7c811ff568
|
|
@ -4197,7 +4197,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
|
||||||
|
|
||||||
public unsafe void Append(byte[] keyBytes, int keyOffset, int keyLength, string value)
|
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])
|
fixed (byte* ptr = &keyBytes[keyOffset])
|
||||||
{
|
{
|
||||||
var pUB = ptr;
|
var pUB = ptr;
|
||||||
|
|
@ -4899,6 +4899,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
key = new string('\0', keyLength);
|
||||||
fixed(char *keyBuffer = key)
|
fixed(char *keyBuffer = key)
|
||||||
{
|
{
|
||||||
if (!AsciiUtilities.TryGetAsciiString(ptr, keyBuffer, keyLength))
|
if (!AsciiUtilities.TryGetAsciiString(ptr, keyBuffer, keyLength))
|
||||||
|
|
|
||||||
|
|
@ -417,7 +417,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
|
||||||
{(loop.ClassName == "FrameRequestHeaders" ? $@"
|
{(loop.ClassName == "FrameRequestHeaders" ? $@"
|
||||||
public unsafe void Append(byte[] keyBytes, int keyOffset, int keyLength, string value)
|
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])
|
fixed (byte* ptr = &keyBytes[keyOffset])
|
||||||
{{
|
{{
|
||||||
var pUB = ptr;
|
var pUB = ptr;
|
||||||
|
|
@ -446,6 +446,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
|
||||||
break;
|
break;
|
||||||
")}}}
|
")}}}
|
||||||
|
|
||||||
|
key = new string('\0', keyLength);
|
||||||
fixed(char *keyBuffer = key)
|
fixed(char *keyBuffer = key)
|
||||||
{{
|
{{
|
||||||
if (!AsciiUtilities.TryGetAsciiString(ptr, keyBuffer, keyLength))
|
if (!AsciiUtilities.TryGetAsciiString(ptr, keyBuffer, keyLength))
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue