[ast] Refactor lazy_static to LazyLock
It is available in Rust 1.80 and reduces a dependency.
This commit is contained in:
parent
202a902cd0
commit
c3927d0ef6
|
@ -634,7 +634,6 @@ name = "nac3ast"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"fxhash",
|
"fxhash",
|
||||||
"lazy_static",
|
|
||||||
"parking_lot",
|
"parking_lot",
|
||||||
"string-interner",
|
"string-interner",
|
||||||
]
|
]
|
||||||
|
|
|
@ -10,7 +10,6 @@ constant-optimization = ["fold"]
|
||||||
fold = []
|
fold = []
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
lazy_static = "1.5"
|
|
||||||
parking_lot = "0.12"
|
parking_lot = "0.12"
|
||||||
string-interner = "0.17"
|
string-interner = "0.17"
|
||||||
fxhash = "0.2"
|
fxhash = "0.2"
|
||||||
|
|
|
@ -5,14 +5,12 @@ pub use crate::location::Location;
|
||||||
|
|
||||||
use fxhash::FxBuildHasher;
|
use fxhash::FxBuildHasher;
|
||||||
use parking_lot::{Mutex, MutexGuard};
|
use parking_lot::{Mutex, MutexGuard};
|
||||||
use std::{cell::RefCell, collections::HashMap, fmt};
|
use std::{cell::RefCell, collections::HashMap, fmt, sync::LazyLock};
|
||||||
use string_interner::{symbol::SymbolU32, DefaultBackend, StringInterner};
|
use string_interner::{symbol::SymbolU32, DefaultBackend, StringInterner};
|
||||||
|
|
||||||
pub type Interner = StringInterner<DefaultBackend, FxBuildHasher>;
|
pub type Interner = StringInterner<DefaultBackend, FxBuildHasher>;
|
||||||
lazy_static! {
|
static INTERNER: LazyLock<Mutex<Interner>> =
|
||||||
static ref INTERNER: Mutex<Interner> =
|
LazyLock::new(|| Mutex::new(StringInterner::with_hasher(FxBuildHasher::default())));
|
||||||
Mutex::new(StringInterner::with_hasher(FxBuildHasher::default()));
|
|
||||||
}
|
|
||||||
|
|
||||||
thread_local! {
|
thread_local! {
|
||||||
static LOCAL_INTERNER: RefCell<HashMap<String, StrRef>> = RefCell::default();
|
static LOCAL_INTERNER: RefCell<HashMap<String, StrRef>> = RefCell::default();
|
||||||
|
|
|
@ -14,9 +14,6 @@
|
||||||
clippy::wildcard_imports
|
clippy::wildcard_imports
|
||||||
)]
|
)]
|
||||||
|
|
||||||
#[macro_use]
|
|
||||||
extern crate lazy_static;
|
|
||||||
|
|
||||||
mod ast_gen;
|
mod ast_gen;
|
||||||
mod constant;
|
mod constant;
|
||||||
#[cfg(feature = "fold")]
|
#[cfg(feature = "fold")]
|
||||||
|
|
Loading…
Reference in New Issue