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

Add (optional) smallvec decode/encode support #705

Open
wants to merge 2 commits into
base: trunk
Choose a base branch
from

Conversation

freqmod
Copy link

@freqmod freqmod commented Mar 17, 2024

I added optional support for the smallvec crate which supports vectors inside a struct without a separate memory allocation. I tried implementing this with the newtype pattern, but i could not figure out a way to deserialise a without going via a vector (and thus allocating the memory that the crate was designed to avoid).

The code is 90% copy paste from the code for (De)coding vectors. However I had to remove the optimisation for deserialising u8 as SmallVec don't use generics for the array size.

I hope that this change can be merged, and am happy to work with you if there are any changes that are needed in order to do so.

We probably also need to update the list of features in the docs. I can do that if necessary.

@adamreichold
Copy link

SmallVec don't use generics for the array size.

They do have a const_generics feature.

@VictorKoenders
Copy link
Contributor

See #612 for previous work and discussion on this

@freqmod
Copy link
Author

freqmod commented Mar 18, 2024

I see, thanks for linking the issue for me. It is a bit strange that I didn't see this issue when I searched in github.
I guess I will have to keep a fork around for now then until bincode v2 is released.

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.

None yet

3 participants