diff --git a/Cargo.lock b/Cargo.lock index 0a3b6231..a3fe1bf1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -53,7 +53,6 @@ dependencies = [ "log", "notify", "objc", - "once_cell", "parking_lot", "png", "raw-window-handle", diff --git a/alacritty/Cargo.toml b/alacritty/Cargo.toml index 519afdb4..5e23a525 100644 --- a/alacritty/Cargo.toml +++ b/alacritty/Cargo.toml @@ -32,7 +32,6 @@ home = "0.5.5" libc = "0.2" log = { version = "0.4", features = ["std", "serde"] } notify = "6.1.1" -once_cell = "1.12" parking_lot = "0.12.0" raw-window-handle = "0.5" serde = { version = "1", features = ["derive"] } diff --git a/alacritty/src/logging.rs b/alacritty/src/logging.rs index 6bede4e7..42f1536e 100644 --- a/alacritty/src/logging.rs +++ b/alacritty/src/logging.rs @@ -8,12 +8,11 @@ use std::fs::{File, OpenOptions}; use std::io::{self, LineWriter, Stdout, Write}; use std::path::PathBuf; use std::sync::atomic::{AtomicBool, Ordering}; -use std::sync::{Arc, Mutex}; +use std::sync::{Arc, Mutex, OnceLock}; use std::time::Instant; use std::{env, process}; use log::{self, Level, LevelFilter}; -use once_cell::sync::Lazy; use winit::event_loop::EventLoopProxy; use crate::cli::Options; @@ -35,10 +34,14 @@ pub const LOG_TARGET_CONFIG: &str = "alacritty_config_derive"; const ALACRITTY_EXTRA_LOG_TARGETS_ENV: &str = "ALACRITTY_EXTRA_LOG_TARGETS"; /// User configurable extra log targets to include. -static EXTRA_LOG_TARGETS: Lazy> = Lazy::new(|| { - env::var(ALACRITTY_EXTRA_LOG_TARGETS_ENV) - .map_or(Vec::new(), |targets| targets.split(';').map(ToString::to_string).collect()) -}); +fn extra_log_targets() -> &'static [String] { + static EXTRA_LOG_TARGETS: OnceLock> = OnceLock::new(); + + EXTRA_LOG_TARGETS.get_or_init(|| { + env::var(ALACRITTY_EXTRA_LOG_TARGETS_ENV) + .map_or(Vec::new(), |targets| targets.split(';').map(ToString::to_string).collect()) + }) +} /// List of targets which will be logged by Alacritty. const ALLOWED_TARGETS: &[&str] = &[ @@ -181,7 +184,7 @@ fn create_log_message(record: &log::Record<'_>, target: &str, start: Instant) -> fn is_allowed_target(level: Level, target: &str) -> bool { match (level, log::max_level()) { (Level::Error, LevelFilter::Trace) | (Level::Warn, LevelFilter::Trace) => true, - _ => ALLOWED_TARGETS.contains(&target) || EXTRA_LOG_TARGETS.iter().any(|t| t == target), + _ => ALLOWED_TARGETS.contains(&target) || extra_log_targets().iter().any(|t| t == target), } } diff --git a/alacritty/src/renderer/mod.rs b/alacritty/src/renderer/mod.rs index d8fd64fa..02bfd762 100644 --- a/alacritty/src/renderer/mod.rs +++ b/alacritty/src/renderer/mod.rs @@ -2,6 +2,7 @@ use std::borrow::Cow; use std::collections::HashSet; use std::ffi::{CStr, CString}; use std::sync::atomic::{AtomicBool, Ordering}; +use std::sync::OnceLock; use std::{fmt, ptr}; use ahash::RandomState; @@ -9,7 +10,6 @@ use crossfont::Metrics; use glutin::context::{ContextApi, GlContext, PossiblyCurrentContext}; use glutin::display::{GetGlDisplay, GlDisplay}; use log::{debug, error, info, warn, LevelFilter}; -use once_cell::sync::OnceCell; use unicode_width::UnicodeWidthChar; use alacritty_terminal::index::Point; @@ -318,7 +318,7 @@ impl GlExtensions { /// /// This function will lazily load OpenGL extensions. fn contains(extension: &str) -> bool { - static OPENGL_EXTENSIONS: OnceCell> = OnceCell::new(); + static OPENGL_EXTENSIONS: OnceLock> = OnceLock::new(); OPENGL_EXTENSIONS.get_or_init(Self::load_extensions).contains(extension) }