Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why not directly use Array.Copy and increment Position? #8

Open
niuk opened this issue Dec 19, 2017 · 2 comments
Open

Why not directly use Array.Copy and increment Position? #8

niuk opened this issue Dec 19, 2017 · 2 comments

Comments

@niuk
Copy link

niuk commented Dec 19, 2017

@HexTank
Copy link

HexTank commented May 3, 2018

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
Copy link

HexTank commented May 3, 2018

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants