Skip to content

Commit 7e3fd7b

Browse files
authored
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
1 parent 00097df commit 7e3fd7b

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

crates/gpui/src/svg_renderer.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ pub enum SvgSize {
2727

2828
impl SvgRenderer {
2929
pub fn new(asset_source: Arc<dyn AssetSource>) -> Self {
30-
let font_db = LazyLock::new(|| {
30+
static FONT_DB: LazyLock<Arc<usvg::fontdb::Database>> = LazyLock::new(|| {
3131
let mut db = usvg::fontdb::Database::new();
3232
db.load_system_fonts();
3333
Arc::new(db)
@@ -36,7 +36,7 @@ impl SvgRenderer {
3636
let font_resolver = Box::new(
3737
move |font: &usvg::Font, db: &mut Arc<usvg::fontdb::Database>| {
3838
if db.is_empty() {
39-
*db = font_db.clone();
39+
*db = FONT_DB.clone();
4040
}
4141
default_font_resolver(font, db)
4242
},

0 commit comments

Comments
 (0)