Skip to content

Commit bc3b585

Browse files
authored
do less work for indenting comment blocks (#469)
1 parent bdce630 commit bc3b585

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

librubyfmt/src/comment_block.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,12 @@ impl CommentBlock {
3636
}
3737

3838
pub fn apply_spaces(mut self, indent_depth: ColNumber) -> Self {
39+
let indent = str::repeat(" ", indent_depth as _);
3940
for comment in &mut self.comments {
4041
// Ignore empty strings -- these represent blank lines between
4142
// groups of comments
4243
if !comment.is_empty() {
43-
*comment = str::repeat(" ", indent_depth as _) + comment
44+
comment.insert_str(0, &indent);
4445
}
4546
}
4647
self

0 commit comments

Comments
 (0)