From 20d4f0e4e449ba475a79805d00ed98aee0b4ba5c Mon Sep 17 00:00:00 2001 From: One <43485962+c-git@users.noreply.github.com> Date: Tue, 6 Feb 2024 22:50:58 -0500 Subject: [PATCH] refactor: remove unnecessary clones on strings --- src/app/data.rs | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/app/data.rs b/src/app/data.rs index 8ae6b98..5395452 100644 --- a/src/app/data.rs +++ b/src/app/data.rs @@ -15,7 +15,8 @@ pub struct LogRow { } impl LogRow { - const EMPTY_TEXT: &'static str = "[-]"; + const EMPTY_TEXT: &'static str = "[ --- ]"; + pub(crate) fn time(&self) -> &str { if let Some(val) = &self.time { val @@ -24,27 +25,27 @@ impl LogRow { } } - pub(crate) fn request_id(&self) -> String { + pub(crate) fn request_id(&self) -> &str { if let Some(val) = &self.request_id { - val.clone() + val } else { - Self::EMPTY_TEXT.to_string() + Self::EMPTY_TEXT } } - pub(crate) fn otel_name(&self) -> String { + pub(crate) fn otel_name(&self) -> &str { if let Some(val) = &self.otel_name { - val.clone() + val } else { - Self::EMPTY_TEXT.to_string() + Self::EMPTY_TEXT } } - pub(crate) fn msg(&self) -> String { + pub(crate) fn msg(&self) -> &str { if let Some(val) = &self.msg { - val.clone() + val } else { - Self::EMPTY_TEXT.to_string() + Self::EMPTY_TEXT } } }