Skip to content

Commit

Permalink
Reduce allocations
Browse files Browse the repository at this point in the history
  • Loading branch information
sinkuu committed Oct 15, 2018
1 parent 6fb188b commit 6c964fd
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/comment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<_>>()
Expand Down
2 changes: 1 addition & 1 deletion src/config/config_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 6c964fd

Please sign in to comment.