1
0
mirror of https://github.com/lidgren/lidgren-network-gen3.git synced 2026-05-17 15:46:33 +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; return retval;
} }
byte[] bytes = System.Text.Encoding.UTF8.GetBytes(text); int numBytes = System.Text.Encoding.UTF8.GetByteCount(text);
retval = CreateIncomingMessage(tp, bytes.Length + (bytes.Length > 127 ? 2 : 1)); retval = CreateIncomingMessage(tp, numBytes + (numBytes > 127 ? 2 : 1));
retval.Write(text); retval.Write(text);
return retval; return retval;