You've already forked lidgren-network-gen3
mirror of
https://github.com/lidgren/lidgren-network-gen3.git
synced 2026-05-16 23:26:32 +09:00
- Fixed various number to avoid re-allocating netbuffer storage
This commit is contained in:
@@ -28,17 +28,17 @@ namespace Lidgren.Network
|
||||
}
|
||||
}
|
||||
|
||||
internal byte[] GetStorage(int minimumCapacity)
|
||||
internal byte[] GetStorage(int minimumCapacityInBytes)
|
||||
{
|
||||
if (m_storagePool == null)
|
||||
return new byte[minimumCapacity];
|
||||
return new byte[minimumCapacityInBytes];
|
||||
|
||||
lock (m_storagePool)
|
||||
{
|
||||
for (int i = 0; i < m_storagePool.Count; i++)
|
||||
{
|
||||
byte[] retval = m_storagePool[i];
|
||||
if (retval != null && retval.Length >= minimumCapacity)
|
||||
if (retval != null && retval.Length >= minimumCapacityInBytes)
|
||||
{
|
||||
m_storagePool[i] = null;
|
||||
m_storagePoolBytes -= retval.Length;
|
||||
@@ -46,8 +46,8 @@ namespace Lidgren.Network
|
||||
}
|
||||
}
|
||||
}
|
||||
m_statistics.m_bytesAllocated += minimumCapacity;
|
||||
return new byte[minimumCapacity];
|
||||
m_statistics.m_bytesAllocated += minimumCapacityInBytes;
|
||||
return new byte[minimumCapacityInBytes];
|
||||
}
|
||||
|
||||
internal void Recycle(byte[] storage)
|
||||
|
||||
Reference in New Issue
Block a user