From c324b0e520d2f9184e23db11ab8bdf18872fcb8d Mon Sep 17 00:00:00 2001 From: Jan-Erik Rediger Date: Thu, 1 Oct 2026 13:57:08 -0400 Subject: [PATCH] Avoid format machinery for concatenating the base identifier all the time --- glean-core/src/common_metric_data.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/glean-core/src/common_metric_data.rs b/glean-core/src/common_metric_data.rs index 180be9f4f3..2800da1992 100644 --- a/glean-core/src/common_metric_data.rs +++ b/glean-core/src/common_metric_data.rs @@ -253,7 +253,12 @@ impl CommonMetricDataInternal { if self.inner.category.is_empty() { self.inner.name.clone() } else { - format!("{}.{}", self.inner.category, self.inner.name) + let mut id = + String::with_capacity(self.inner.category.len() + self.inner.name.len() + 1); + id.push_str(&self.inner.category); + id.push('.'); + id.push_str(&self.inner.name); + id } } @@ -306,11 +311,11 @@ impl CommonMetricDataInternal { } MetricLabel::KeyOnly(key, static_category) => { validate_dual_label_sqlite(tx, &base_identifier, key, "") - .map(|key| format!("{key}{static_category}")) + .map(|key| [&key[..], &static_category[..]].concat()) } MetricLabel::CategoryOnly(static_key, category) => { validate_dual_label_sqlite(tx, &base_identifier, "", category) - .map(|category| format!("{static_key}{category}")) + .map(|category| [&static_key[..], &category[..]].concat()) } MetricLabel::KeyAndCategory(key, category) => { validate_dual_label_sqlite(tx, &base_identifier, key, category)