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
This commit is contained in:
parent
00097df0d5
commit
7e3fd7bb02
1 changed files with 2 additions and 2 deletions
|
@ -27,7 +27,7 @@ pub enum SvgSize {
|
|||
|
||||
impl SvgRenderer {
|
||||
pub fn new(asset_source: Arc<dyn AssetSource>) -> Self {
|
||||
let font_db = LazyLock::new(|| {
|
||||
static FONT_DB: LazyLock<Arc<usvg::fontdb::Database>> = 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<usvg::fontdb::Database>| {
|
||||
if db.is_empty() {
|
||||
*db = font_db.clone();
|
||||
*db = FONT_DB.clone();
|
||||
}
|
||||
default_font_resolver(font, db)
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue