From 7e3fd7bb020077383947950f4e899c258d48c2aa Mon Sep 17 00:00:00 2001 From: tidely <43219534+tidely@users.noreply.github.com> Date: Fri, 18 Jul 2025 13:35:38 +0300 Subject: [PATCH] gpui: Use static keyword with `LazyLock` when loading system fonts (#34555) Use the `static` keyword to actually make the `LazyLock` static, which previously would reinitialize on every call to `SvgRenderer::new`. Related: #26335 Release Notes: - N/A --- crates/gpui/src/svg_renderer.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/gpui/src/svg_renderer.rs b/crates/gpui/src/svg_renderer.rs index 08d281b850ca80a370130e9f364d6ecb5334a1ce..0107624bc8d0e6a26c6acc4a085cbddc7e14c4c5 100644 --- a/crates/gpui/src/svg_renderer.rs +++ b/crates/gpui/src/svg_renderer.rs @@ -27,7 +27,7 @@ pub enum SvgSize { impl SvgRenderer { pub fn new(asset_source: Arc) -> Self { - let font_db = LazyLock::new(|| { + static FONT_DB: LazyLock> = LazyLock::new(|| { let mut db = usvg::fontdb::Database::new(); db.load_system_fonts(); Arc::new(db) @@ -36,7 +36,7 @@ impl SvgRenderer { let font_resolver = Box::new( move |font: &usvg::Font, db: &mut Arc| { if db.is_empty() { - *db = font_db.clone(); + *db = FONT_DB.clone(); } default_font_resolver(font, db) },