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

forward specialized BytesMut methods on {Encode,Decode}Buf #1358

Closed

Conversation

srijs
Copy link
Contributor

@srijs srijs commented Apr 16, 2023

Forwards more Buf/BufMut methods on EncodeBuf and DecodeBuf to take advantage of specialized implementations on BytesMut, where available.

Motivation

BytesMut has some optimized variants of Buf and BufMut methods that users of EncodeBuf and DecodeBuf currently miss out on. In particular, an O(1) zero-copy variant of Buf::copy_to_bytes and variants of BufMut::put and BufMut::put_slice that elide checking remaining_mut/advance_mut.

Solution

Provide specialized implementations of Buf::copy_to_bytes on DecodeBuf as well as ButMut::put and BufMut::put_slice on EncodeBuf which forward these calls onto the underlying BytesMut implementations.

@srijs srijs force-pushed the forward-buf-mut-specialized-methods branch from b4750d1 to 49deac2 Compare April 16, 2023 13:00
@srijs srijs force-pushed the forward-buf-mut-specialized-methods branch from 49deac2 to eb779db Compare April 16, 2023 13:32
ClementTsang added a commit to DataDog/tonic that referenced this pull request May 2, 2024
ClementTsang added a commit to DataDog/tonic that referenced this pull request May 2, 2024
@tottoto
Copy link
Collaborator

tottoto commented Sep 20, 2024

Thanks. Seems to be addressed at #1695.

@tottoto tottoto closed this Sep 20, 2024
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