Skip to content

Commit fcf637b

Browse files
committed
Auto merge of #24519 - rprichard:opt-write-args, r=alexcrichton
It's just as convenient, but it's much faster. Using write! requires an extra call to fmt::write and a extra dynamically dispatched call to Arguments' Display format function.
2 parents ba11928 + 317eac3 commit fcf637b

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

src/libcollections/fmt.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -443,6 +443,6 @@ use string;
443443
#[stable(feature = "rust1", since = "1.0.0")]
444444
pub fn format(args: Arguments) -> string::String {
445445
let mut output = string::String::new();
446-
let _ = write!(&mut output, "{}", args);
446+
let _ = output.write_fmt(args);
447447
output
448448
}

src/libstd/rt/unwind.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,7 @@ pub fn begin_unwind_fmt(msg: fmt::Arguments, file_line: &(&'static str, u32)) ->
504504
// below).
505505

506506
let mut s = String::new();
507-
let _ = write!(&mut s, "{}", msg);
507+
let _ = s.write_fmt(msg);
508508
begin_unwind_inner(Box::new(s), file_line)
509509
}
510510

src/libstd/rt/util.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ pub const ENFORCE_SANITY: bool = true || !cfg!(rtopt) || cfg!(rtdebug) ||
6565
cfg!(rtassert);
6666

6767
pub fn dumb_print(args: fmt::Arguments) {
68-
let _ = write!(&mut Stderr::new(), "{}", args);
68+
let _ = Stderr::new().write_fmt(args);
6969
}
7070

7171
pub fn abort(args: fmt::Arguments) -> ! {

0 commit comments

Comments
 (0)