Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

toByteBuffer optimizations #427

Merged
merged 3 commits into from
Apr 4, 2023

Conversation

armanbilge
Copy link
Contributor

  1. toByteBuffer should only return a read-only buffer if necessary to protect its internals. Read-only buffers don't allow access to the underlying array which can force further copies downstream. If the data is already being copied, then there is no reason to return a read-only buffer.

  2. Add toByteBufferUnsafe. In the spirit of toArrayUnsafe, but can avoid copies in several more situations e.g. a view of a slice of an array. This will enable copy-free transforms to Chunk.ArraySlice in FS2.

@armanbilge armanbilge changed the title ByteBuffer optimizations toByteBuffer optimizations Apr 4, 2023
@mpilquist mpilquist merged commit cf14aaf into scodec:main Apr 4, 2023
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants