1
0
mirror of https://github.com/lidgren/lidgren-network-gen3.git synced 2026-05-06 02:11:06 +09:00

Removed unnecessary allocation

This commit is contained in:
lidgren
2014-08-12 20:44:39 +00:00
parent c2f8346ca3
commit 715746eed3
2 changed files with 5 additions and 7 deletions

View File

@@ -84,10 +84,8 @@ namespace Lidgren.Network
/// </summary>
public NetOutgoingMessage CreateMessage(string content)
{
byte[] bytes = Encoding.UTF8.GetBytes(content);
NetOutgoingMessage om = CreateMessage(2 + bytes.Length);
om.WriteVariableUInt32((uint)bytes.Length);
om.Write(bytes);
var om = CreateMessage(2 + content.Length); // fair guess
om.Write(content);
return om;
}
@@ -101,8 +99,8 @@ namespace Lidgren.Network
if (m_outgoingMessagesPool == null || !m_outgoingMessagesPool.TryDequeue(out retval))
retval = new NetOutgoingMessage();
byte[] storage = GetStorage(initialCapacity);
retval.m_data = storage;
if (initialCapacity > 0)
retval.m_data = GetStorage(initialCapacity);
return retval;
}