1
0
Fork 0
mirror of https://github.com/alacritty/alacritty.git synced 2024-11-25 14:05:41 -05:00

Remove direct dependency on once_cell

With MSRV 1.70, std now contains the necessary parts.
This commit is contained in:
Philip Dubé 2023-12-29 01:40:18 +00:00 committed by Christian Duerr
parent 047152acb8
commit 01d7640569
4 changed files with 12 additions and 11 deletions

1
Cargo.lock generated
View file

@ -53,7 +53,6 @@ dependencies = [
"log",
"notify",
"objc",
"once_cell",
"parking_lot",
"png",
"raw-window-handle",

View file

@ -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"] }

View file

@ -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),
}
}

View file

@ -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)
}