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

Optimize CodedInputStream.readByteBuffer() for LiteralByteString #676

Closed
wants to merge 1 commit into from

Conversation

stepancheg
Copy link

With this patch applied CodedInputStream.readByteBuffer() returns
ByteBuffer wrapping array contained in LiteralByteString. To
ensure that LiteralByteString is not modified, returned buffer
is made readonly with .asReadOnlyBuffer() operation.

With this patch applied `CodedInputStream.readByteBuffer()` returns
`ByteBuffer` wrapping array contained in `LiteralByteString`.  To
ensure that `LiteralByteString` is not modified, returned buffer
is made readonly with `.asReadOnlyBuffer()` operation.
@googlebot
Copy link

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project, in which case you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed, please reply here (e.g. I signed it!) and we'll verify. Thanks.


  • If you've already signed a CLA, it's possible we don't have your GitHub username or you're using a different email address. Check your existing CLA data and verify that your email is set on your git commits.
  • If you signed the CLA as a corporation, please let us know the company's name.

@stepancheg
Copy link
Author

I signed it! (as stepan.koltsov@gmail.com)

@googlebot
Copy link

CLAs look good, thanks!

@googlebot googlebot added cla: yes and removed cla: no labels Aug 2, 2015
@xfxyjwf xfxyjwf self-assigned this Jun 23, 2018
@xfxyjwf xfxyjwf added the java label Jun 23, 2018
ByteBuffer result;
if (input == null && enableAliasing) {
if (bufferIsImmutable) {
result = ByteBuffer.wrap(buffer, bufferPos, size).asReadOnlyBuffer().slice();
Copy link
Contributor

Choose a reason for hiding this comment

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

This is an API breaking change. readByteBuffer() should return a mutable buffer, not a read-only one.

@xfxyjwf xfxyjwf closed this Jun 23, 2018
adellahlou pushed a commit to adellahlou/protobuf that referenced this pull request Apr 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants