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

Use write_str instead of write_fmt when no formatting is needed #1008

Merged
merged 1 commit into from
Nov 25, 2020

Conversation

MarijnS95
Copy link
Contributor

write_fmt (what write! expands to) needs to be set up with an std::fmt::Arguments object that is consequently iterated. All segments of the format string get Display::fmt called on them and those implementations usually result in calling some form of write_str (at least for &str).

This is a minor change that only saves few unnecessary cyles and is mostly done for cosmetic reasons. It finishes the work started in 3eaed54.


This follows a discussion in gtk-rs/gtk3-rs#155. The change results in hundreds of file changes in gtk-rs which is a lot of noise to bear. The new format of f.write_str("Some string literal") is nicer to read though, and we're already making massive changes with the docs anyhow.

Write_fmt (what write! expands to) needs to be set up with an
std::fmt::Arguments object that is consequently iterated.  All segments
of the format string get Display::fmt called on them and those
implementations usually result in calling some form of write_str (at
least for &str).

This is a minor change that only saves few unnecessary cyles and is
mostly done for cosmetic reasons.  It finishes the work started in
3eaed54.
@sdroege sdroege merged commit 9a2e43b into gtk-rs:master Nov 25, 2020
@MarijnS95 MarijnS95 deleted the write_str branch November 25, 2020 21:18
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