ReliableNetcode.NET icon indicating copy to clipboard operation
ReliableNetcode.NET copied to clipboard

Why not directly use Array.Copy and increment Position?

Open niuk opened this issue 7 years ago • 2 comments

https://github.com/KillaMaaki/ReliableNetcode.NET/blob/09fba6a45ebb6f0d9d2be23bcd15c65b40b6c773/ReliableNetcode/Utils/IO/ByteStream.cs#L198-L202

niuk avatar Dec 19 '17 19:12 niuk

I guess the Read function could use some love too, something like..

		public override int Read(byte[] buffer, int offset, int count)
		{
			long pos = this.Position;
			long len = this.Length;
			int readBytes = (int)Math.Min(count, len - pos);
			Array.Copy(srcByteArray, pos, buffer, offset, readBytes);
			this.Position = pos + readBytes;
			return readBytes;
		}

HexTank avatar May 03 '18 16:05 HexTank

I also notice the Write doesn't deal with any buffer overflows like Read does. Not sure if that's important and is dealt with elsewhere.

HexTank avatar May 03 '18 16:05 HexTank