Replace lazy_static with std::sync::LazyLock in components/fonts (#33049)

* replace in shaper.rs

Signed-off-by: Hayashi Mikihiro <34ttrweoewiwe28@gmail.com>

* replace in android/font_list.rs

Signed-off-by: Hayashi Mikihiro <34ttrweoewiwe28@gmail.com>

* replace in ohos/font_list.rs

Signed-off-by: Hayashi Mikihiro <34ttrweoewiwe28@gmail.com>

* remove lazy_lock from components/fonts

Signed-off-by: Hayashi Mikihiro <34ttrweoewiwe28@gmail.com>

---------

Signed-off-by: Hayashi Mikihiro <34ttrweoewiwe28@gmail.com>
This commit is contained in:
Hayashi Mikihiro 2024-08-15 01:20:54 +09:00 committed by GitHub
parent 7633bdccd2
commit ad85dd10e3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 17 additions and 22 deletions

View file

@ -5,6 +5,7 @@
use std::fs::File;
use std::io::Read;
use std::path::Path;
use std::sync::LazyLock;
use base::text::{is_cjk, UnicodeBlock, UnicodeBlockMethod};
use log::warn;
@ -21,9 +22,7 @@ use crate::{
FallbackFontSelectionOptions, FontTemplate, FontTemplateDescriptor, LowercaseFontFamilyName,
};
lazy_static::lazy_static! {
static ref FONT_LIST: FontList = FontList::new();
}
static FONT_LIST: LazyLock<FontList> = LazyLock::new(|| FontList::new());
/// An identifier for a local font on Android systems.
#[derive(Clone, Debug, Deserialize, Eq, Hash, MallocSizeOf, PartialEq, Serialize)]

View file

@ -7,6 +7,7 @@ use std::fs::File;
use std::io::Read;
use std::os::unix::ffi::OsStrExt;
use std::path::{Path, PathBuf};
use std::sync::LazyLock;
use std::{fs, io};
use base::text::{UnicodeBlock, UnicodeBlockMethod};
@ -25,9 +26,7 @@ use crate::{
FontTemplateDescriptor, LowercaseFontFamilyName,
};
lazy_static::lazy_static! {
static ref FONT_LIST: FontList = FontList::new();
}
static FONT_LIST: LazyLock<FontList> = LazyLock::new(|| FontList::new());
/// When testing the ohos font code on linux, we can pass the fonts directory of the SDK
/// via an environment variable.