Presize MemoryStream when possible.

Also use GetBuffer when we know we have presized the stream to the exact required size to prevent a needless copy.
This commit is contained in:
RoosterDragon
2017-12-07 21:28:43 +00:00
committed by abcdefg30
parent 5d8c9a560a
commit ca01a1f186
7 changed files with 19 additions and 13 deletions

View File

@@ -49,7 +49,7 @@ namespace OpenRA.Server
public byte[] Serialize()
{
var ms = new MemoryStream();
var ms = new MemoryStream(1 + Name.Length + 1 + Data.Length + 1);
var bw = new BinaryWriter(ms);
bw.Write((byte)0xfe);