Replace the lazy_static crate whth std::sync::LazyLock in components/script (#33004)

* replace in str.rs

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

* replace navigator.rs

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

* replace htmlmetaelement.rs

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

* replace document.rs

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

* replace cssstyledeclaration.rs

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

* replace script_runtime.rs

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

* replace window_named_properties.rs

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

* reduce dependency lazy_static

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

* reduce lazy in script_runtime.rs

 `Mutex::new()`  is const contexts. I think that `JS_ENGINE` is need not lazy initialize.

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-12 16:30:35 +09:00 committed by GitHub
parent f38d1574bc
commit a797969efe
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 98 additions and 104 deletions

View file

@ -4,10 +4,10 @@
use std::cell::Cell;
use std::convert::TryInto;
use std::sync::LazyLock;
use dom_struct::dom_struct;
use js::jsval::JSVal;
use lazy_static::lazy_static;
use crate::dom::bindings::cell::DomRefCell;
use crate::dom::bindings::codegen::Bindings::NavigatorBinding::NavigatorMethods;
@ -32,9 +32,8 @@ use crate::dom::xrsystem::XRSystem;
use crate::script_runtime::JSContext;
pub(super) fn hardware_concurrency() -> u64 {
lazy_static! {
static ref CPUS: u64 = num_cpus::get().try_into().unwrap_or(1);
}
static CPUS: LazyLock<u64> = LazyLock::new(|| num_cpus::get().try_into().unwrap_or(1));
*CPUS
}