mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
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:
parent
f38d1574bc
commit
a797969efe
9 changed files with 98 additions and 104 deletions
|
@ -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
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue