perf(net): borrow inbound packet storage
Decode headers, optional fields, fragments, and single-fragment messages directly over pooled datagrams. Copy only fragment state that crosses a datagram lifetime, preserve synchronous dispatch and ACK ordering, and lock the path to the owned decoder with differential and zero-allocation tests.
This commit is contained in:
parent
7211bb1bf7
commit
e928c5dd02
18 changed files with 1329 additions and 66 deletions
|
|
@ -35,16 +35,16 @@ public static class EmoteText
|
|||
string SenderName,
|
||||
string Text);
|
||||
|
||||
public static Parsed? TryParse(byte[] body)
|
||||
public static Parsed? TryParse(ReadOnlySpan<byte> body)
|
||||
{
|
||||
if (body is null || body.Length < 8) return null;
|
||||
if (body.Length < 8) return null;
|
||||
uint opcode = BinaryPrimitives.ReadUInt32LittleEndian(body);
|
||||
if (opcode != Opcode) return null;
|
||||
|
||||
try
|
||||
{
|
||||
int pos = 4;
|
||||
uint senderGuid = BinaryPrimitives.ReadUInt32LittleEndian(body.AsSpan(pos));
|
||||
uint senderGuid = BinaryPrimitives.ReadUInt32LittleEndian(body.Slice(pos));
|
||||
pos += 4;
|
||||
string senderName = StringReader.ReadString16L(body, ref pos);
|
||||
string text = StringReader.ReadString16L(body, ref pos);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue