Skip to content

Commit f6cef57

Browse files
committed
Auto merge of #95905 - vacuus:markdown-render, r=GuillaumeGomez
rustdoc: Reduce allocations in a `markdown` function Not `html::markdown` this time, just `markdown`, haha.
2 parents 52ca603 + ab3ab4d commit f6cef57

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/librustdoc/markdown.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use std::fmt::Write as _;
12
use std::fs::{create_dir_all, read_to_string, File};
23
use std::io::prelude::*;
34
use std::path::Path;
@@ -51,8 +52,8 @@ crate fn render<P: AsRef<Path>>(
5152

5253
let mut css = String::new();
5354
for name in &options.markdown_css {
54-
let s = format!("<link rel=\"stylesheet\" type=\"text/css\" href=\"{name}\">\n");
55-
css.push_str(&s)
55+
write!(css, r#"<link rel="stylesheet" type="text/css" href="{name}">"#)
56+
.expect("Writing to a String can't fail");
5657
}
5758

5859
let input_str = read_to_string(input).map_err(|err| format!("{}: {}", input.display(), err))?;

0 commit comments

Comments
 (0)