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

Optimize bincode::deserialize #122

Closed
dtolnay opened this issue Feb 23, 2017 · 1 comment
Closed

Optimize bincode::deserialize #122

dtolnay opened this issue Feb 23, 2017 · 1 comment

Comments

@dtolnay
Copy link
Collaborator

@dtolnay dtolnay commented Feb 23, 2017

pub fn deserialize<T>(bytes: &[u8]) -> Result<T>
    where T: serde::Deserialize
{
    let mut reader = bytes;
    deserialize_from(&mut reader, SizeLimit::Infinite)
}

This function is inefficient because in addition to a bunch of sizelimit-related branching (cc #121) the deserializer is forced to perform two writes for every time it reads from the input - once within self.reader and another to update self.read - even though self.read is never going to be used.

A specialized implementation for &[u8] would enable optimizing this case to perform just a single write - cc #119.

@TyOverby
Copy link
Collaborator

@TyOverby TyOverby commented Oct 14, 2017

Fixed a long time ago with the SizeLimit trait

@TyOverby TyOverby closed this Oct 14, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.