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:
@@ -261,14 +261,14 @@ namespace OpenRA.Network
|
||||
{
|
||||
var ms = new MemoryStream();
|
||||
ms.Write(packet.Length);
|
||||
ms.WriteArray(packet);
|
||||
ms.Write(packet);
|
||||
|
||||
foreach (var s in queuedSyncPackets)
|
||||
{
|
||||
var q = OrderIO.SerializeSync(s);
|
||||
|
||||
ms.Write(q.Length);
|
||||
ms.WriteArray(q);
|
||||
ms.Write(q);
|
||||
|
||||
sentSync.Enqueue(s);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user