summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--crates/typst/src/eval/str.rs6
1 files changed, 5 insertions, 1 deletions
diff --git a/crates/typst/src/eval/str.rs b/crates/typst/src/eval/str.rs
index e7df00e1..666c3c72 100644
--- a/crates/typst/src/eval/str.rs
+++ b/crates/typst/src/eval/str.rs
@@ -591,7 +591,11 @@ impl Str {
/// Reverse the string.
#[func(title = "Reverse")]
pub fn rev(&self) -> Str {
- self.as_str().graphemes(true).rev().collect::<String>().into()
+ let mut s = EcoString::with_capacity(self.0.len());
+ for grapheme in self.as_str().graphemes(true).rev() {
+ s.push_str(grapheme);
+ }
+ s.into()
}
}