mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 22:31:43 +00:00
switch to once_cell from lazy_static
This commit is contained in:
parent
70cd5ffbf5
commit
1667b5cf52
5 changed files with 28 additions and 22 deletions
|
@ -1,13 +1,14 @@
|
|||
use std::cell::RefCell;
|
||||
use std::time::{Duration, Instant};
|
||||
use std::mem;
|
||||
use std::io::{stderr, Write};
|
||||
use std::iter::repeat;
|
||||
use std::collections::{HashSet};
|
||||
use std::default::Default;
|
||||
use std::iter::FromIterator;
|
||||
use std::sync::{RwLock, atomic::{AtomicBool, Ordering}};
|
||||
use lazy_static::lazy_static;
|
||||
use std::{
|
||||
cell::RefCell,
|
||||
time::{Duration, Instant},
|
||||
mem,
|
||||
io::{stderr, Write},
|
||||
iter::repeat,
|
||||
collections::HashSet,
|
||||
sync::{RwLock, atomic::{AtomicBool, Ordering}},
|
||||
};
|
||||
|
||||
use once_cell::sync::Lazy;
|
||||
|
||||
/// Set profiling filter. It specifies descriptions allowed to profile.
|
||||
/// This is helpful when call stack has too many nested profiling scopes.
|
||||
|
@ -21,7 +22,7 @@ use lazy_static::lazy_static;
|
|||
/// ```
|
||||
pub fn set_filter(f: Filter) {
|
||||
PROFILING_ENABLED.store(f.depth > 0, Ordering::SeqCst);
|
||||
let set = HashSet::from_iter(f.allowed.iter().cloned());
|
||||
let set: HashSet<_> = f.allowed.iter().cloned().collect();
|
||||
let mut old = FILTER.write().unwrap();
|
||||
let filter_data = FilterData {
|
||||
depth: f.depth,
|
||||
|
@ -161,9 +162,7 @@ struct FilterData {
|
|||
|
||||
static PROFILING_ENABLED: AtomicBool = AtomicBool::new(false);
|
||||
|
||||
lazy_static! {
|
||||
static ref FILTER: RwLock<FilterData> = RwLock::new(Default::default());
|
||||
}
|
||||
static FILTER: Lazy<RwLock<FilterData>> = Lazy::new(Default::default);
|
||||
|
||||
thread_local!(static PROFILE_STACK: RefCell<ProfileStack> = RefCell::new(ProfileStack::new()));
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue