Skip to content

Commit

Permalink
Pre-allocate result string
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Mar 19, 2016
1 parent ce09f31 commit 4e44fdc
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ fn unindent(input: token::InternedString) -> String {
.min()
.unwrap_or(0);

let mut result = String::new();
let mut result = String::with_capacity(input.len());
for (i, line) in input.lines().enumerate() {
if i > 1 || (i == 1 && !ignore_first_line) {
result.push_str("\n");
Expand Down

0 comments on commit 4e44fdc

Please sign in to comment.