Skip to content

Commit 3f49744

Browse files
committed
perf(roff): Remove extra allocations
1 parent d5351f4 commit 3f49744

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

crates/anstyle-roff/src/lib.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,11 @@ fn set_effects_and_text(styled: &StyledStr<'_>, doc: &mut Roff) {
7272
// perhaps by spinning off some of this code
7373
let effects = styled.style.get_effects();
7474
if effects.contains(anstyle::Effects::BOLD) | has_bright_fg(&styled.style) {
75-
doc.text(vec![bold(styled.text)]);
75+
doc.text([bold(styled.text)]);
7676
} else if effects.contains(anstyle::Effects::ITALIC) {
77-
doc.text(vec![italic(styled.text)]);
77+
doc.text([italic(styled.text)]);
7878
} else {
79-
doc.text(vec![roff::roman(styled.text)]);
79+
doc.text([roff::roman(styled.text)]);
8080
}
8181
}
8282

@@ -116,13 +116,13 @@ fn add_color_to_roff(doc: &mut Roff, control_request: &str, color: &Option<Color
116116
let name = rgb_name(c);
117117
doc.control(
118118
control_requests::CREATE_COLOR,
119-
vec![name.as_str(), "rgb", to_hex(c).as_str()],
119+
[name.as_str(), "rgb", to_hex(c).as_str()],
120120
)
121-
.control(control_request, vec![name.as_str()]);
121+
.control(control_request, [name.as_str()]);
122122
}
123123

124124
Some(Color::Ansi(c)) => {
125-
doc.control(control_request, vec![ansi_color_to_roff(c)]);
125+
doc.control(control_request, [ansi_color_to_roff(c)]);
126126
}
127127
Some(Color::Ansi256(c)) => {
128128
// Adding Support for Ansi256 colors, however cansi does not support
@@ -132,7 +132,7 @@ fn add_color_to_roff(doc: &mut Roff, control_request: &str, color: &Option<Color
132132
}
133133
None => {
134134
// TODO: get rid of "default" hardcoded str?
135-
doc.control(control_request, vec!["default"]);
135+
doc.control(control_request, ["default"]);
136136
}
137137
}
138138
}

0 commit comments

Comments
 (0)