1
0
mirror of https://github.com/lidgren/lidgren-network-gen3.git synced 2026-05-15 22:56:30 +09:00

CreateIncomingMessage(tp, text) optimized to allocate less memory

This commit is contained in:
lidgren
2011-07-20 08:39:41 +00:00
parent 39459f6833
commit aa20b0893d

View File

@@ -182,8 +182,8 @@ namespace Lidgren.Network
return retval;
}
byte[] bytes = System.Text.Encoding.UTF8.GetBytes(text);
retval = CreateIncomingMessage(tp, bytes.Length + (bytes.Length > 127 ? 2 : 1));
int numBytes = System.Text.Encoding.UTF8.GetByteCount(text);
retval = CreateIncomingMessage(tp, numBytes + (numBytes > 127 ? 2 : 1));
retval.Write(text);
return retval;