Use spans to improve performance in StreamExts.
Also avoid ReadBytes calls that allocate a buffer by either updating the stream position (if not interested in the bytes), by reusing an input buffer (if interested in the bytes), or using a stackalloc buffer to avoid the allocation (for small reads).
This commit is contained in:
@@ -67,7 +67,7 @@ namespace OpenRA.Network
|
||||
}
|
||||
}
|
||||
|
||||
file.WriteArray(initialContent);
|
||||
file.Write(initialContent);
|
||||
writer = new BinaryWriter(file);
|
||||
}
|
||||
|
||||
@@ -93,7 +93,7 @@ namespace OpenRA.Network
|
||||
{
|
||||
var ms = new MemoryStream(4 + data.Length);
|
||||
ms.Write(frame);
|
||||
ms.WriteArray(data);
|
||||
ms.Write(data);
|
||||
Receive(clientID, ms.GetBuffer());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user