Assets/Deps/emotitron/Network/GenericNetworkExt.cs
/// <summary>
/// Alternative to HLAPI NetworkReader ReadBytes(), which creates a new byte[] every time. This reuses a byte[] and reads the bytes in
/// one at a time, hopefully eliminating GC.
/// </summary>
/// <param name="reader"></param>
/// <param name="count"></param>
/// <returns>Returns the same byte array as the on in the arguments.</returns>
Alternative to HLAPI NetworkReader ReadBytes(), which creates a new byte[] every time. This reuses a byte[] and reads the bytes in
one at a time, hopefully eliminating GC.
Alternative to HLAPI NetworkReader ReadBytes () which creates a new byte [] every time . This reuses a byte [] and reads the bytes in one at a time hopefully eliminating GC .
public static byte[] ReadBytesNonAlloc(this NetworkReader reader, byte[] targetbytearray, int count = -1)
	{
		if (count == -1)
			count = targetbytearray.Length;
		for (int i = 0; i < count; i++)
		{
			targetbytearray[i] = reader.ReadByte();
		}
		return targetbytearray;
	}
public static byte [ ] ReadBytesNonAlloc ( this NetworkReader reader , byte [ ] targetbytearray , int count = - 1 ) { if ( count == - 1 ) count = targetbytearray . Length ; for ( int i = 0 ; i < count ; i ++ ) { targetbytearray [ i ] = reader . ReadByte ( ) ; } return targetbytearray ; }
Alternative to HLAPI NetworkReader ReadBytes(), which creates a new byte[] every time.
Alternative to HLAPI NetworkReader ReadBytes () which creates a new byte [] every time .
Returns the same byte array as the on in the arguments.
Returns the same byte array as the on in the arguments .
NetworkReader
this
targetbytearray
byte[]
count
int
None
reader
None