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 performance by using write_str instead of write! when there are no formatting arguments #285

Closed
nyurik opened this issue Feb 7, 2024 · 0 comments · Fixed by #286

Comments

@nyurik
Copy link
Contributor

nyurik commented Feb 7, 2024

Apparently when using write!("anything without arguments"), the compiler generates considerable additional code, resulting in bigger binaries and likely slower performance. I tried it with https://rust.godbolt.org/z/Y8djWsq1P

I would like to replace write!(f, ...) with f.write_str(...) in the generated code.

P.S. This issue is also tracked in rust-lang/rust#99012 - but it appears to be highly complex and nowhere near being solved in a near future, thus warranting a workaround at least in the popular crates.

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 a pull request may close this issue.

1 participant