Avoid allocating intermediate strings in ItemizedBlock::trimmed_block_as_string
This commit is contained in:
parent
40909b4331
commit
9d407bfd1b
1 changed files with 5 additions and 4 deletions
|
|
@ -533,10 +533,11 @@ impl ItemizedBlock {
|
|||
|
||||
/// Returns the block as a string, with each line trimmed at the start.
|
||||
fn trimmed_block_as_string(&self) -> String {
|
||||
self.lines
|
||||
.iter()
|
||||
.map(|line| format!("{} ", line.trim_start()))
|
||||
.collect::<String>()
|
||||
self.lines.iter().fold(String::new(), |mut acc, line| {
|
||||
acc.push_str(line.trim_start());
|
||||
acc.push(' ');
|
||||
acc
|
||||
})
|
||||
}
|
||||
|
||||
/// Returns the block as a string under its original form.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue