Web: remove unnecessary usage of once_cell::unsync::Lazy (#3134)

This commit is contained in:
daxpedda 2023-10-08 02:00:51 +02:00 committed by GitHub
parent 48a1e84906
commit f5dd1c008c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 13 additions and 15 deletions

View file

@ -2,7 +2,7 @@ use std::cell::Cell;
use std::rc::Rc;
use js_sys::Promise;
use once_cell::unsync::{Lazy, OnceCell};
use once_cell::unsync::OnceCell;
use wasm_bindgen::closure::Closure;
use wasm_bindgen::prelude::wasm_bindgen;
use wasm_bindgen::{JsCast, JsValue};
@ -65,7 +65,7 @@ impl FullscreenHandler {
if has_fullscreen_api_support(&self.canvas) {
thread_local! {
static REJECT_HANDLER: Lazy<Closure<dyn FnMut(JsValue)>> = Lazy::new(|| Closure::new(|_| ()));
static REJECT_HANDLER: Closure<dyn FnMut(JsValue)> = Closure::new(|_| ());
}
REJECT_HANDLER.with(|handler| {
let _ = canvas.request_fullscreen().catch(handler);

View file

@ -1,5 +1,4 @@
use js_sys::{Array, Object};
use once_cell::unsync::Lazy;
use wasm_bindgen::prelude::{wasm_bindgen, Closure};
use wasm_bindgen::{JsCast, JsValue};
use web_sys::{
@ -292,7 +291,7 @@ impl Drop for ResizeScaleInternal {
// See <https://bugs.webkit.org/show_bug.cgi?id=219005>.
pub fn has_device_pixel_support() -> bool {
thread_local! {
static DEVICE_PIXEL_SUPPORT: Lazy<bool> = Lazy::new(|| {
static DEVICE_PIXEL_SUPPORT: bool = {
#[wasm_bindgen]
extern "C" {
type ResizeObserverEntryExt;
@ -307,8 +306,8 @@ pub fn has_device_pixel_support() -> bool {
&JsValue::from_str("devicePixelContentBoxSize"),
);
!descriptor.is_undefined()
});
};
}
DEVICE_PIXEL_SUPPORT.with(|support| **support)
DEVICE_PIXEL_SUPPORT.with(|support| *support)
}

View file

@ -1,5 +1,5 @@
use js_sys::{Function, Object, Promise, Reflect};
use once_cell::unsync::{Lazy, OnceCell};
use once_cell::unsync::OnceCell;
use std::time::Duration;
use wasm_bindgen::closure::Closure;
use wasm_bindgen::prelude::wasm_bindgen;
@ -73,7 +73,7 @@ impl Schedule {
}
thread_local! {
static REJECT_HANDLER: Lazy<Closure<dyn FnMut(JsValue)>> = Lazy::new(|| Closure::new(|_| ()));
static REJECT_HANDLER: Closure<dyn FnMut(JsValue)> = Closure::new(|_| ());
}
REJECT_HANDLER.with(|handler| {
let _ = scheduler