mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-14 17:48:10 +00:00
Reduce allocations
This commit is contained in:
parent
6fb188bd43
commit
6c964fd030
@ -764,12 +764,12 @@ fn trim_custom_comment_prefix(s: &str) -> String {
|
||||
// due to comment wrapping, a line that was originaly behind `#` is split over
|
||||
// multiple lines, which needs then to be prefixed with a `#`
|
||||
if !orig.trim_left().starts_with("# ") {
|
||||
format!("# {}", orig)
|
||||
Cow::from(format!("# {}", orig))
|
||||
} else {
|
||||
orig.to_string()
|
||||
Cow::from(orig)
|
||||
}
|
||||
} else {
|
||||
line.to_string()
|
||||
Cow::from(line)
|
||||
}
|
||||
})
|
||||
.collect::<Vec<_>>()
|
||||
|
@ -112,7 +112,7 @@ macro_rules! create_config {
|
||||
cloned.width_heuristics = None;
|
||||
|
||||
::toml::to_string(&cloned)
|
||||
.map_err(|e| format!("Could not output config: {}", e.to_string()))
|
||||
.map_err(|e| format!("Could not output config: {}", e))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -779,7 +779,7 @@ pub fn format_impl(
|
||||
let outer_indent_str = offset.block_only().to_string_with_newline(context.config);
|
||||
|
||||
result.push_str(&inner_indent_str);
|
||||
result.push_str(visitor.buffer.to_string().trim());
|
||||
result.push_str(visitor.buffer.trim());
|
||||
result.push_str(&outer_indent_str);
|
||||
} else if need_newline || !context.config.empty_item_single_line() {
|
||||
result.push_str(&sep);
|
||||
@ -1137,7 +1137,7 @@ pub fn format_trait(context: &RewriteContext, item: &ast::Item, offset: Indent)
|
||||
let inner_indent_str = visitor.block_indent.to_string_with_newline(context.config);
|
||||
|
||||
result.push_str(&inner_indent_str);
|
||||
result.push_str(visitor.buffer.to_string().trim());
|
||||
result.push_str(visitor.buffer.trim());
|
||||
result.push_str(&outer_indent_str);
|
||||
} else if result.contains('\n') {
|
||||
result.push_str(&outer_indent_str);
|
||||
|
Loading…
Reference in New Issue
Block a user