-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Open
Labels
A-fmtArea: `core::fmt`Area: `core::fmt`C-bugCategory: This is a bug.Category: This is a bug.I-heavyIssue: Problems and improvements with respect to binary size of generated code.Issue: Problems and improvements with respect to binary size of generated code.I-slowIssue: Problems and improvements with respect to performance of generated code.Issue: Problems and improvements with respect to performance of generated code.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
I was using write!
in a lot of places, some I just do write!(writer, " ")
but I noticed that the generated assembly is not as good as writer.write_all(b" ")
. Since we have minimal const fn
now, I wonder if we could improve the generated assembly when a single character or a single argument is passed in.
use std::io::{self, Write};
pub fn write_char(buf: &mut Vec<u8>) -> io::Result<()> {
write!(buf, " ")
}
use std::io::{self, Write};
pub fn write_char(buf: &mut Vec<u8>) -> io::Result<()> {
buf.write_all(b" ")
}
https://rust.godbolt.org/z/zzEMjd
I also write!()
could accept a single byte or character. Example, write!(buf, ' ')
.
If anyone can mentor, maybe I can take on this part (hopefully without compiling rust).
Meta
rustc --version --verbose
:
nigthly
CC @lzutao
Metadata
Metadata
Assignees
Labels
A-fmtArea: `core::fmt`Area: `core::fmt`C-bugCategory: This is a bug.Category: This is a bug.I-heavyIssue: Problems and improvements with respect to binary size of generated code.Issue: Problems and improvements with respect to binary size of generated code.I-slowIssue: Problems and improvements with respect to performance of generated code.Issue: Problems and improvements with respect to performance of generated code.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.