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

uses serde_bytes for (de)serializing Vec<u8> #4088

Merged
merged 1 commit into from
Dec 13, 2024

Conversation

behzadnouri
Copy link

Problem

By default Vec<u8> is treated just as any Vec<T> and is inefficiently (de)serialized byte by byte.
serde_bytes instead uses Serializer::serialize_bytes and Deserializer::deserialize_bytes which do so more efficiently.
https://docs.rs/serde/latest/serde/trait.Serializer.html#tymethod.serialize_bytes
https://docs.rs/serde/latest/serde/trait.Deserializer.html#tymethod.deserialize_bytes

Summary of Changes

The commit uses serde_bytes for (de)serializing Vec<u8>.

By default Vec<u8> is treated just as any Vec<T> and is inefficiently
(de)serialized byte by byte.
serde_bytes instead uses Serializer::serialize_bytes and
Deserializer::deserialize_bytes which do so more efficiently.
https://docs.rs/serde/latest/serde/trait.Serializer.html#tymethod.serialize_bytes
https://docs.rs/serde/latest/serde/trait.Deserializer.html#tymethod.deserialize_bytes
Copy link

@gregcusack gregcusack left a comment

Choose a reason for hiding this comment

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

lgtm!

@behzadnouri behzadnouri merged commit f70d6b6 into anza-xyz:master Dec 13, 2024
51 checks passed
@behzadnouri behzadnouri deleted the serde-bytes-all branch December 13, 2024 14:01
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