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 Chunk#to{Byte,Char}Buffer, add note about mutability #3147

Merged
merged 3 commits into from
Feb 19, 2023

Conversation

armanbilge
Copy link
Member

We had some unsuspended uses of toByteBuffer which I am fixing in d76bdea.

Comment on lines -315 to +318
val b = c.buf.asReadOnlyBuffer
val b = c.buf.duplicate // share contents, independent position/limit
Copy link
Member Author

Choose a reason for hiding this comment

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

asReadOnlyBuffer and duplicate are similar in that the returned buffer has independent position/limit.

The difference is that a read-only buffer denies access to its underlying Array, while a duplicated buffer does not. Being able to get at that array is an important optimization.

@mpilquist mpilquist merged commit a70daca into typelevel:main Feb 19, 2023
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

Successfully merging this pull request may close these issues.

2 participants