aboutsummaryrefslogtreecommitdiff
path: root/helix-term/src/ui/markdown.rs
diff options
context:
space:
mode:
authorMichael Davis2023-07-26 15:26:56 +0000
committerBlaž Hrastnik2023-07-27 02:50:19 +0000
commit953073a679dfe8ae4aff86e8a9bff680d14a5523 (patch)
tree1d9dcc47314f176aee48b3e54bbd63126fd3624f /helix-term/src/ui/markdown.rs
parent98ef05d768d287fef2eb790e0a8a6e9a72832e00 (diff)
highlighted_code_block: Take input text as &str
This removes a handful of allocations for functions calling into the function, which is nice because the prompt may call this function on every keypress.
Diffstat (limited to 'helix-term/src/ui/markdown.rs')
-rw-r--r--helix-term/src/ui/markdown.rs6
1 files changed, 3 insertions, 3 deletions
diff --git a/helix-term/src/ui/markdown.rs b/helix-term/src/ui/markdown.rs
index cb2abf68..1433381d 100644
--- a/helix-term/src/ui/markdown.rs
+++ b/helix-term/src/ui/markdown.rs
@@ -17,7 +17,7 @@ use helix_view::{
Theme,
};
-fn styled_multiline_text<'a>(text: String, style: Style) -> Text<'a> {
+fn styled_multiline_text<'a>(text: &str, style: Style) -> Text<'a> {
let spans: Vec<_> = text
.lines()
.map(|line| Span::styled(line.to_string(), style))
@@ -27,7 +27,7 @@ fn styled_multiline_text<'a>(text: String, style: Style) -> Text<'a> {
}
pub fn highlighted_code_block<'a>(
- text: String,
+ text: &str,
language: &str,
theme: Option<&Theme>,
config_loader: Arc<syntax::Loader>,
@@ -267,7 +267,7 @@ impl Markdown {
CodeBlockKind::Indented => "",
};
let tui_text = highlighted_code_block(
- text.to_string(),
+ &text,
language,
theme,
Arc::clone(&self.config_loader),