Skip to content

Commit

Permalink
Auto merge of rust-lang#24519 - rprichard:opt-write-args, r=alexcrichton
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
bors committed Apr 18, 2015
2 parents ba11928 + 317eac3 commit fcf637b
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/libcollections/fmt.rs
Expand Up @@ -443,6 +443,6 @@ use string;
#[stable(feature = "rust1", since = "1.0.0")]
pub fn format(args: Arguments) -> string::String {
let mut output = string::String::new();
let _ = write!(&mut output, "{}", args);
let _ = output.write_fmt(args);
output
}
2 changes: 1 addition & 1 deletion src/libstd/rt/unwind.rs
Expand Up @@ -504,7 +504,7 @@ pub fn begin_unwind_fmt(msg: fmt::Arguments, file_line: &(&'static str, u32)) ->
// below).

let mut s = String::new();
let _ = write!(&mut s, "{}", msg);
let _ = s.write_fmt(msg);
begin_unwind_inner(Box::new(s), file_line)
}

Expand Down
2 changes: 1 addition & 1 deletion src/libstd/rt/util.rs
Expand Up @@ -65,7 +65,7 @@ pub const ENFORCE_SANITY: bool = true || !cfg!(rtopt) || cfg!(rtdebug) ||
cfg!(rtassert);

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

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

0 comments on commit fcf637b

Please sign in to comment.