Skip to content

Commit

Permalink
refactor: remove unnecessary clones on strings
Browse files Browse the repository at this point in the history
  • Loading branch information
c-git committed Feb 7, 2024
1 parent 26f5d37 commit 20d4f0e
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions src/app/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
}
}
}
Expand Down

0 comments on commit 20d4f0e

Please sign in to comment.