From 8f0721f00aca257809a52af8c4bf8876053b6bbe Mon Sep 17 00:00:00 2001 From: Nik Revenco <154856872+NikitaRevenco@users.noreply.github.com> Date: Mon, 24 Mar 2025 16:07:19 +0000 Subject: [PATCH] use format! instead of preallocating this is more efficient apparently --- helix-stdx/src/time.rs | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/helix-stdx/src/time.rs b/helix-stdx/src/time.rs index a7bb1a040..cb72a9386 100644 --- a/helix-stdx/src/time.rs +++ b/helix-stdx/src/time.rs @@ -71,11 +71,5 @@ pub fn format_relative_time(timestamp: i64, timezone_offset: i32) -> String { "from now" }; - let mut relative_time = String::with_capacity(value.len() + 1 + unit.len() + 1 + label.len()); - relative_time.push_str(&value); - relative_time.push(' '); - relative_time.push_str(unit); - relative_time.push(' '); - relative_time.push_str(label); - relative_time + format!("{value} {unit} {label}") }