From c059bab6f4aa920326167b861a3ae17f53001070 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20W=C3=BClker?= Date: Wed, 14 Aug 2024 15:42:01 +0200 Subject: [PATCH] Dont use lazy static to construct mutexes (#33047) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Remove usage of lazy-static in background_hang_monitor The lazy-static crate was only used to construct a mutex, but since Mutex::new is const this can be done at compiletime instead. Signed-off-by: Simon Wülker * Remove usage of lazy-static in servoshell Lazy-static was only used to construct a mutex, but since Mutex::new is const this can simply be done at compiletime. Signed-off-by: Simon Wülker --------- Signed-off-by: Simon Wülker --- Cargo.lock | 2 -- components/background_hang_monitor/Cargo.toml | 3 --- .../background_hang_monitor/tests/hang_monitor_tests.rs | 4 +--- ports/servoshell/Cargo.toml | 1 - ports/servoshell/resources.rs | 4 +--- 5 files changed, 2 insertions(+), 12 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 08cf1ce84a4..a0a4ed44084 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -291,7 +291,6 @@ dependencies = [ "base", "crossbeam-channel", "ipc-channel", - "lazy_static", "libc", "log", "mach2", @@ -6187,7 +6186,6 @@ dependencies = [ "ipc-channel", "jni", "keyboard-types", - "lazy_static", "libc", "libloading", "libservo", diff --git a/components/background_hang_monitor/Cargo.toml b/components/background_hang_monitor/Cargo.toml index 604131013ba..598d81f8e91 100644 --- a/components/background_hang_monitor/Cargo.toml +++ b/components/background_hang_monitor/Cargo.toml @@ -22,9 +22,6 @@ libc = { workspace = true } log = { workspace = true } serde_json = { workspace = true } -[dev-dependencies] -lazy_static = { workspace = true } - [target.'cfg(target_os = "macos")'.dependencies] mach2 = "0.4" diff --git a/components/background_hang_monitor/tests/hang_monitor_tests.rs b/components/background_hang_monitor/tests/hang_monitor_tests.rs index 36a6b45eec3..a35ef7bfda4 100644 --- a/components/background_hang_monitor/tests/hang_monitor_tests.rs +++ b/components/background_hang_monitor/tests/hang_monitor_tests.rs @@ -17,9 +17,7 @@ use background_hang_monitor_api::{ use base::id::TEST_PIPELINE_ID; use ipc_channel::ipc; -lazy_static::lazy_static! { - static ref SERIAL: Mutex<()> = Mutex::new(()); -} +static SERIAL: Mutex<()> = Mutex::new(()); #[test] fn test_hang_monitoring() { diff --git a/ports/servoshell/Cargo.toml b/ports/servoshell/Cargo.toml index 2e7bf1fe8e2..0573067796b 100644 --- a/ports/servoshell/Cargo.toml +++ b/ports/servoshell/Cargo.toml @@ -56,7 +56,6 @@ libc = { workspace = true } libservo = { path = "../../components/servo" } cfg-if = { workspace = true } log = { workspace = true } -lazy_static = { workspace = true } getopts = { workspace = true } url = { workspace = true } servo-media = { workspace = true } diff --git a/ports/servoshell/resources.rs b/ports/servoshell/resources.rs index 8a713522785..fe65dfafa5c 100644 --- a/ports/servoshell/resources.rs +++ b/ports/servoshell/resources.rs @@ -9,9 +9,7 @@ use std::{env, fs}; use cfg_if::cfg_if; use servo::embedder_traits::resources::{self, Resource}; -lazy_static::lazy_static! { - static ref CMD_RESOURCE_DIR: Mutex> = Mutex::new(None); -} +static CMD_RESOURCE_DIR: Mutex> = Mutex::new(None); struct ResourceReader;