Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Avoid doing string manipulation on render for single line label (#23227)
Michael Sloan972176a57437
diff --git a/crates/ui/src/components/label/label.rs b/crates/ui/src/components/label/label.rsindex 5ec557d7e69..a2034ff8ae0 100644--- a/crates/ui/src/components/label/label.rs+++ b/crates/ui/src/components/label/label.rs@@ -36,7 +36,6 @@ use crate::{prelude::*, LabelCommon, LabelLike, LabelSize, LineHeightStyle};pub struct Label {base: LabelLike,label: SharedString,- single_line: bool,}impl Label {@@ -53,7 +52,6 @@ impl Label {Self {base: LabelLike::new(),label: label.into(),- single_line: false,}}}@@ -170,7 +168,7 @@ impl LabelCommon for Label {}fn single_line(mut self) -> Self {- self.single_line = true;+ self.label = SharedString::from(self.label.replace('\n', ""));self.base = self.base.single_line();self}@@ -178,11 +176,6 @@ impl LabelCommon for Label {impl RenderOnce for Label {fn render(self, _cx: &mut WindowContext) -> impl IntoElement {- let target_label = if self.single_line {- SharedString::from(self.label.replace('\n', ""))- } else {- self.label- };- self.base.child(target_label)+ self.base.child(self.label)}}