From 5101b395569bad4cfe3175e92d266a63efab2289 Mon Sep 17 00:00:00 2001 From: extrawurst Date: Fri, 2 Sep 2022 09:17:34 +0200 Subject: [PATCH] switch from lazy_static to once_cell --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/components/utils/emoji.rs | 8 +++----- src/ui/syntax_text.rs | 10 ++++------ 4 files changed, 9 insertions(+), 13 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index eccd6a15..720dbdd3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -672,8 +672,8 @@ dependencies = [ "fuzzy-matcher", "gh-emoji", "itertools", - "lazy_static", "log", + "once_cell", "pprof", "pretty_assertions", "rayon-core", diff --git a/Cargo.toml b/Cargo.toml index 512f90e8..79d5cf29 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -36,8 +36,8 @@ filetreelist = { path = "./filetreelist", version = "0.5" } fuzzy-matcher = "0.3" gh-emoji = { version = "1.0", optional = true } itertools = "0.10" -lazy_static = "1.4" log = "0.4" +once_cell = "1" rayon-core = "1.9" ron = "0.8" scopeguard = "1.1" diff --git a/src/components/utils/emoji.rs b/src/components/utils/emoji.rs index 4d158cb9..75fe84dc 100644 --- a/src/components/utils/emoji.rs +++ b/src/components/utils/emoji.rs @@ -1,10 +1,8 @@ -use lazy_static::lazy_static; +use once_cell::sync::Lazy; use std::borrow::Cow; -lazy_static! { - static ref EMOJI_REPLACER: gh_emoji::Replacer = - gh_emoji::Replacer::new(); -} +static EMOJI_REPLACER: Lazy = + Lazy::new(gh_emoji::Replacer::new); // Replace markdown emojis with Unicode equivalent // :hammer: --> 🔨 diff --git a/src/ui/syntax_text.rs b/src/ui/syntax_text.rs index 5c6271aa..ea02bdc1 100644 --- a/src/ui/syntax_text.rs +++ b/src/ui/syntax_text.rs @@ -2,7 +2,7 @@ use asyncgit::{ asyncjob::{AsyncJob, RunParams}, ProgressPercent, }; -use lazy_static::lazy_static; +use once_cell::sync::Lazy; use scopetime::scope_time; use std::{ ffi::OsStr, @@ -32,11 +32,9 @@ pub struct SyntaxText { path: PathBuf, } -lazy_static! { - static ref SYNTAX_SET: SyntaxSet = - SyntaxSet::load_defaults_nonewlines(); - static ref THEME_SET: ThemeSet = ThemeSet::load_defaults(); -} +static SYNTAX_SET: Lazy = + Lazy::new(SyntaxSet::load_defaults_nonewlines); +static THEME_SET: Lazy = Lazy::new(ThemeSet::load_defaults); pub struct AsyncProgressBuffer { current: usize,