Skip to content

Removed string allocation for booleans #49

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

vallentin
Copy link

Title and code says it all :)

Copy link

@dtolnay dtolnay left a comment

Choose a reason for hiding this comment

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

An alternative to consider would be changing call_to_string:

    fn call_to_string<T>(&mut self, v: &T) -> Result<()>
    where
        T: std::fmt::Display,
    {
        use std::fmt::Write as _;
        write!(self.output, "{}", v).unwrap();
        Ok(())
    }

That removes string allocation for not just bool but all the other calls too.

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