diff --git a/Cargo.toml b/Cargo.toml index 8eacd68..cbd04d0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -75,7 +75,6 @@ frunk = ["mysql_common/frunk"] binlog = ["mysql_common/binlog"] [dev-dependencies] -lazy_static = "1.4.0" rand = "0.8.2" serde_derive = "1" time = "0.3" @@ -90,7 +89,6 @@ flate2 = { version = "1.0", default-features = false } lru = "0.12" mysql_common = { version = "0.32", default-features = false } socket2 = "0.5.2" -once_cell = "1.7.2" pem = "3" percent-encoding = "2.1.0" serde = "1" diff --git a/src/buffer_pool/enabled.rs b/src/buffer_pool/enabled.rs index d2af5fd..88c33f3 100644 --- a/src/buffer_pool/enabled.rs +++ b/src/buffer_pool/enabled.rs @@ -1,18 +1,20 @@ #![cfg(feature = "buffer-pool")] use crossbeam::queue::ArrayQueue; -use once_cell::sync::Lazy; -use std::{mem::take, ops::Deref, sync::Arc}; +use std::{ + mem::take, + ops::Deref, + sync::{Arc, OnceLock}, +}; const DEFAULT_MYSQL_BUFFER_POOL_CAP: usize = 128; const DEFAULT_MYSQL_BUFFER_SIZE_CAP: usize = 4 * 1024 * 1024; -static BUFFER_POOL: Lazy> = Lazy::new(Default::default); - #[inline(always)] pub fn get_buffer() -> Buffer { - BUFFER_POOL.get() + static BUFFER_POOL: OnceLock> = OnceLock::new(); + BUFFER_POOL.get_or_init(Default::default).get() } #[derive(Debug)] diff --git a/src/lib.rs b/src/lib.rs index a0660ba..693667a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1060,8 +1060,6 @@ macro_rules! doctest_wrapper { #[cfg(test)] mod test_misc { - use lazy_static::lazy_static; - use crate::{def_database_url, def_get_opts}; #[allow(dead_code)] @@ -1070,8 +1068,9 @@ mod test_misc { _dummy(crate::error::Error::FromValueError(crate::Value::NULL)); } - lazy_static! { - pub static ref DATABASE_URL: String = def_database_url!(); + #[allow(dead_code)] + fn database_url() { + def_database_url!(); } def_get_opts!();