diff options
author | Philip Dubé <serprex@users.noreply.github.com> | 2023-12-29 01:40:18 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-29 01:40:18 +0000 |
commit | 91e3cd6a40aa98cf9a76e7cd3534f7fbb0a27098 (patch) | |
tree | ddb1dab94eca886b33cc9b5cd57a4d0e36c8fb90 | |
parent | 81df32af60147941c7d6005cf55ffd14c9665734 (diff) | |
download | alacritty-91e3cd6a40aa98cf9a76e7cd3534f7fbb0a27098.tar.gz alacritty-91e3cd6a40aa98cf9a76e7cd3534f7fbb0a27098.zip |
Remove direct dependency on once_cell
With MSRV 1.70, std now contains the necessary parts.
-rw-r--r-- | Cargo.lock | 1 | ||||
-rw-r--r-- | alacritty/Cargo.toml | 1 | ||||
-rw-r--r-- | alacritty/src/logging.rs | 17 | ||||
-rw-r--r-- | alacritty/src/renderer/mod.rs | 4 |
4 files changed, 12 insertions, 11 deletions
@@ -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 44b048b2..ad732cfd 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<Vec<String>> = 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<Vec<String>> = 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<HashSet<&'static str, RandomState>> = OnceCell::new(); + static OPENGL_EXTENSIONS: OnceLock<HashSet<&'static str, RandomState>> = OnceLock::new(); OPENGL_EXTENSIONS.get_or_init(Self::load_extensions).contains(extension) } |