-
Notifications
You must be signed in to change notification settings - Fork 659
Add Peek API for Multiple Integers #3175
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
Conversation
Motivation: The current readMultipleIntegers methods are used to consume multiple integer values at once, but lack an equivalent nonmutating API. This can lead to unnecessary complexity when users want to inspect values without advancing readerIndex. THis patch introduces peekMultipleIntegers which uses the current readerIndex, improving safety. This extends previous work on peek methods (issue apple#2034, issue apple#2736). Modifications: Updated the generation script (.sh file) to produce peekMultipleIntegers variants for each arity of readMultipleIntegers. Added new tests mirroring the existing multi-read/write tests Result: Users can now inspect multiple integer values in a ByteBuffer without consuming them, enabling safer workflows.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great, thanks for contributing it. I've spotted a couple of very minor things but overall this looks good.
Hello! Before I update this branch because it's out-of-date, I wanted to know what the correct practice is here. Should I rebase and force push, or should I simply merge the latest changes to this branch which creates a new commit? Thanks! |
Just use the "Update branch" button below which defaults to updating with a merge commit. We squash and rebase onto main when PRs are merged so it doesn't matter too much either way. |
Got it, thanks : ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice, thanks!
Motivation:
The current readMultipleIntegers methods are used to consume multiple integer values at once, but lack an equivalent nonmutating API. This can lead to unnecessary complexity when users want to inspect values without advancing readerIndex. THis patch introduces peekMultipleIntegers which uses the current readerIndex, improving safety. This extends previous work on peek methods (issue #2034, issue #2736).
Modifications:
Result:
Users can now inspect multiple integer values in a ByteBuffer without consuming them, enabling safer workflows.