Skip to content

Commit 008b3df

Browse files
Rawkytmimi
authored andcommitted
Avoid allocating Vec in light_rewrite_comment
1 parent 019578f commit 008b3df

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

Diff for: src/comment.rs

+3-5
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
use std::{borrow::Cow, iter};
44

5-
use itertools::{MultiPeek, multipeek};
5+
use itertools::{Itertools as _, MultiPeek, multipeek};
66
use rustc_span::Span;
77
use tracing::{debug, trace};
88

@@ -1056,8 +1056,7 @@ fn light_rewrite_comment(
10561056
config: &Config,
10571057
is_doc_comment: bool,
10581058
) -> String {
1059-
let lines: Vec<&str> = orig
1060-
.lines()
1059+
orig.lines()
10611060
.map(|l| {
10621061
// This is basically just l.trim(), but in the case that a line starts
10631062
// with `*` we want to leave one space before it, so it aligns with the
@@ -1075,8 +1074,7 @@ fn light_rewrite_comment(
10751074
// Preserve markdown's double-space line break syntax in doc comment.
10761075
trim_end_unless_two_whitespaces(left_trimmed, is_doc_comment)
10771076
})
1078-
.collect();
1079-
lines.join(&format!("\n{}", offset.to_string(config)))
1077+
.join(&format!("\n{}", offset.to_string(config)))
10801078
}
10811079

10821080
/// Trims comment characters and possibly a single space from the left of a string.

0 commit comments

Comments
 (0)