Skip to content

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

Merged
merged 5 commits into from
Apr 10, 2025
Merged

Conversation

RaghavRoy145
Copy link
Contributor

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:

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.

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

@rnro rnro left a 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.

@RaghavRoy145
Copy link
Contributor Author

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!

@glbrntt
Copy link
Contributor

glbrntt commented Apr 9, 2025

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.

@RaghavRoy145
Copy link
Contributor Author

Got it, thanks : )

Copy link
Contributor

@Lukasa Lukasa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice, thanks!

@Lukasa Lukasa requested a review from rnro April 9, 2025 14:37
@Lukasa Lukasa added the 🆕 semver/minor Adds new public API. label Apr 10, 2025
@Lukasa Lukasa enabled auto-merge (squash) April 10, 2025 09:54
@Lukasa Lukasa merged commit 12d8a4c into apple:main Apr 10, 2025
40 of 41 checks passed
@RaghavRoy145 RaghavRoy145 deleted the peek-multiple-int branch April 10, 2025 11:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🆕 semver/minor Adds new public API.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants