Skip to content

Implement bincode2 encode/decode support for smallvec v1 #375

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

Merged
merged 4 commits into from
Apr 5, 2025

Conversation

markbt
Copy link

@markbt markbt commented Apr 4, 2025

We would like to use bincode v2 to encode some structures that contain smallvecs. Now that bincode v2 has been released, we can add optional implementations of its traits to smallvec.

This PR implements support in smallvec v1 if the optional impl_bincode feature is specified. Similarly to how bincode has optimizations for Vec<u8>, it includes optimizations for SmallVec<[u8; N]>.

Note that I have not updated the existing dev-dependency on bincode that is used in tests. This is because bincode v2 has a fairly high MSRV (1.85.0).

markbt added 2 commits March 26, 2025 15:36
We want to add an optional dependency on bincode 2.  The MSRV of bincode 2
is too high for us to use it in the tests, so rename the test usage to
bincode1 in preparation.
Add implementations for `bincode`'s `Encode`, `Decode` and `BorrowDecode`.

Like `bincode` itself, we implement optimizations when the vector item is `u8` so that `SmallVec<[u8; N]>` can be encoded and decoded with just a memory copy.
Copy link
Collaborator

@mbrubeck mbrubeck left a comment

Choose a reason for hiding this comment

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

Thanks, this looks good!

@mbrubeck mbrubeck merged commit aeceb0a into servo:v1 Apr 5, 2025
7 checks passed
facebook-github-bot pushed a commit to facebookexperimental/rust-shed that referenced this pull request Apr 18, 2025
Summary:
Vendor smallvec v1 with support for bincode v2 encoding and decoding.

This was implemented in PR servo/rust-smallvec#375 which is in release 1.15.0.

Reviewed By: RajivTS

Differential Revision: D72465918

fbshipit-source-id: 04ddf5c05de7d3a9d5dea619dca331f46a40943b
facebook-github-bot pushed a commit to facebook/sapling that referenced this pull request Apr 18, 2025
Summary:
Vendor smallvec v1 with support for bincode v2 encoding and decoding.

This was implemented in PR servo/rust-smallvec#375 which is in release 1.15.0.

Reviewed By: RajivTS

Differential Revision: D72465918

fbshipit-source-id: 04ddf5c05de7d3a9d5dea619dca331f46a40943b
facebook-github-bot pushed a commit to facebook/fbthrift that referenced this pull request Apr 18, 2025
Summary:
Vendor smallvec v1 with support for bincode v2 encoding and decoding.

This was implemented in PR servo/rust-smallvec#375 which is in release 1.15.0.

Reviewed By: RajivTS

Differential Revision: D72465918

fbshipit-source-id: 04ddf5c05de7d3a9d5dea619dca331f46a40943b
facebook-github-bot pushed a commit to facebookincubator/reindeer that referenced this pull request Apr 18, 2025
Summary:
Vendor smallvec v1 with support for bincode v2 encoding and decoding.

This was implemented in PR servo/rust-smallvec#375 which is in release 1.15.0.

Reviewed By: RajivTS

Differential Revision: D72465918

fbshipit-source-id: 04ddf5c05de7d3a9d5dea619dca331f46a40943b
facebook-github-bot pushed a commit to facebook/hhvm that referenced this pull request Apr 18, 2025
Summary:
Vendor smallvec v1 with support for bincode v2 encoding and decoding.

This was implemented in PR servo/rust-smallvec#375 which is in release 1.15.0.

Reviewed By: RajivTS

Differential Revision: D72465918

fbshipit-source-id: 04ddf5c05de7d3a9d5dea619dca331f46a40943b
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