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

Is there are particular design reason why you can't Dequeue without Array Copy? #7

Open
pha3z opened this issue Aug 29, 2019 · 1 comment

Comments

@pha3z
Copy link

pha3z commented Aug 29, 2019

Dequeue always performs an array copy and returns the bytes.

If consumer Peeks at the data, consumer now has the byte array. Consumer can follow up with a dequeue to remove the bytes from the buffer, but consumer does not necessarily need the byte array returned because consumer already has it.

It seems desireable to be able to Peek at byte buffer, and then Dequeue it without performing a needless array copy.

To me it makes sense to add a VoidDequeue method that allows dequeuing without return. Is there a particular reason this is not implemented?

@ygoe
Copy link
Owner

ygoe commented Jan 19, 2020

I probably never needed such a method. It's been a while, but I guess I looked at .NET's Queue class and its methods when I created this API. So there's Dequeue and Peek. I don't know when I actually used such a Peek method myself. So there should be no reason not to add a void-dequeue operation.

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