Skip to content

Commit

Permalink
uucore: remove lazy_static & use LazyLock instead
Browse files Browse the repository at this point in the history
  • Loading branch information
cakebaker committed Mar 5, 2025
1 parent 0f9b36b commit 3b9b8c5
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 8 deletions.
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion src/uucore/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ dunce = { version = "1.0.4", optional = true }
wild = "2.2.1"
glob = { workspace = true }
iana-time-zone = { workspace = true }
lazy_static = "1.4.0"
# * optional
itertools = { workspace = true, optional = true }
thiserror = { workspace = true, optional = true }
Expand Down
10 changes: 4 additions & 6 deletions src/uucore/src/lib/features/checksum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
// spell-checker:ignore anotherfile invalidchecksum regexes JWZG FFFD xffname prefixfilename bytelen bitlen hexdigit

use data_encoding::BASE64;
use lazy_static::lazy_static;
use os_display::Quotable;
use regex::bytes::{Match, Regex};
use std::{
Expand All @@ -16,6 +15,7 @@ use std::{
io::{self, stdin, BufReader, Read, Write},
path::Path,
str,
sync::LazyLock,
};

use crate::{
Expand Down Expand Up @@ -478,11 +478,9 @@ const DOUBLE_SPACE_REGEX: &str = r"^(?P<checksum>[a-fA-F0-9]+)\s{2}(?P<filename>
// In this case, we ignore the *
const SINGLE_SPACE_REGEX: &str = r"^(?P<checksum>[a-fA-F0-9]+)\s(?P<filename>\*?(?-u:.*))$";

lazy_static! {
static ref R_ALGO_BASED: Regex = Regex::new(ALGO_BASED_REGEX).unwrap();
static ref R_DOUBLE_SPACE: Regex = Regex::new(DOUBLE_SPACE_REGEX).unwrap();
static ref R_SINGLE_SPACE: Regex = Regex::new(SINGLE_SPACE_REGEX).unwrap();
}
static R_ALGO_BASED: LazyLock<Regex> = LazyLock::new(|| Regex::new(ALGO_BASED_REGEX).unwrap());
static R_DOUBLE_SPACE: LazyLock<Regex> = LazyLock::new(|| Regex::new(DOUBLE_SPACE_REGEX).unwrap());
static R_SINGLE_SPACE: LazyLock<Regex> = LazyLock::new(|| Regex::new(SINGLE_SPACE_REGEX).unwrap());

#[derive(Debug, PartialEq, Eq, Clone, Copy)]
enum LineFormat {
Expand Down

0 comments on commit 3b9b8c5

Please sign in to comment.