diff --git a/Cargo.lock b/Cargo.lock index 3a21d20..39ef478 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -347,7 +347,6 @@ dependencies = [ "normpath", "nu-ansi-term", "num_cpus", - "once_cell", "regex", "regex-syntax", "tempfile", diff --git a/Cargo.toml b/Cargo.toml index fceaeb2..3746c26 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,7 +18,7 @@ readme = "README.md" repository = "https://github.com/sharkdp/fd" version = "8.7.0" edition= "2021" -rust-version = "1.67.0" +rust-version = "1.70.0" [badges.appveyor] repository = "sharkdp/fd" @@ -47,7 +47,6 @@ globset = "0.4" anyhow = "1.0" dirs-next = "2.0" normpath = "1.1.1" -once_cell = "1.17.2" crossbeam-channel = "0.5.8" clap_complete = {version = "4.3.0", optional = true} faccess = "0.2.4" diff --git a/src/dir_entry.rs b/src/dir_entry.rs index db0a636..3a19d59 100644 --- a/src/dir_entry.rs +++ b/src/dir_entry.rs @@ -1,11 +1,10 @@ +use std::cell::OnceCell; use std::ffi::OsString; use std::fs::{FileType, Metadata}; use std::path::{Path, PathBuf}; use lscolors::{Colorable, LsColors, Style}; -use once_cell::unsync::OnceCell; - use crate::config::Config; use crate::filesystem::strip_current_dir; diff --git a/src/exec/mod.rs b/src/exec/mod.rs index 0fa4d4c..891d764 100644 --- a/src/exec/mod.rs +++ b/src/exec/mod.rs @@ -9,11 +9,10 @@ use std::io; use std::iter; use std::path::{Component, Path, PathBuf, Prefix}; use std::process::Stdio; -use std::sync::Mutex; +use std::sync::{Mutex, OnceLock}; use anyhow::{bail, Result}; use argmax::Command; -use once_cell::sync::Lazy; use regex::Regex; use crate::exit_codes::{merge_exitcodes, ExitCode}; @@ -231,8 +230,7 @@ impl CommandTemplate { I: IntoIterator, S: AsRef, { - static PLACEHOLDER_PATTERN: Lazy = - Lazy::new(|| Regex::new(r"\{(/?\.?|//)\}").unwrap()); + static PLACEHOLDER_PATTERN: OnceLock = OnceLock::new(); let mut args = Vec::new(); let mut has_placeholder = false; @@ -243,7 +241,10 @@ impl CommandTemplate { let mut tokens = Vec::new(); let mut start = 0; - for placeholder in PLACEHOLDER_PATTERN.find_iter(arg) { + let pattern = + PLACEHOLDER_PATTERN.get_or_init(|| Regex::new(r"\{(/?\.?|//)\}").unwrap()); + + for placeholder in pattern.find_iter(arg) { // Leading text before the placeholder. if placeholder.start() > start { tokens.push(Token::Text(arg[start..placeholder.start()].to_owned())); diff --git a/src/filter/size.rs b/src/filter/size.rs index 5df60ab..249e03f 100644 --- a/src/filter/size.rs +++ b/src/filter/size.rs @@ -1,9 +1,9 @@ +use std::sync::OnceLock; + use anyhow::anyhow; -use once_cell::sync::Lazy; use regex::Regex; -static SIZE_CAPTURES: Lazy = - Lazy::new(|| Regex::new(r"(?i)^([+-]?)(\d+)(b|[kmgt]i?b?)$").unwrap()); +static SIZE_CAPTURES: OnceLock = OnceLock::new(); #[derive(Clone, Copy, Debug, PartialEq, Eq)] pub enum SizeFilter { @@ -31,11 +31,13 @@ impl SizeFilter { } fn parse_opt(s: &str) -> Option { - if !SIZE_CAPTURES.is_match(s) { + let pattern = + SIZE_CAPTURES.get_or_init(|| Regex::new(r"(?i)^([+-]?)(\d+)(b|[kmgt]i?b?)$").unwrap()); + if !pattern.is_match(s) { return None; } - let captures = SIZE_CAPTURES.captures(s)?; + let captures = pattern.captures(s)?; let limit_kind = captures.get(1).map_or("+", |m| m.as_str()); let quantity = captures .get(2)