aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorbors[bot] <bors[bot]@users.noreply.github.com>2019-05-07 18:54:57 +0100
committerbors[bot] <bors[bot]@users.noreply.github.com>2019-05-07 18:54:57 +0100
commit6ceaea9e9505cfa07c0a76b590b62fa9615061cd (patch)
treed7dee875aad8182a83195dba6d767d26dcff53d3 /crates
parent70cd5ffbf5f2283fc4986c581d225987620b5335 (diff)
parent1667b5cf52a8f2854c7299242820c951eab50f7a (diff)
Merge #1255
1255: switch to once_cell from lazy_static r=matklad a=matklad Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates')
-rw-r--r--crates/ra_assists/Cargo.toml2
-rw-r--r--crates/ra_assists/src/ast_editor.rs6
-rw-r--r--crates/ra_prof/Cargo.toml2
-rw-r--r--crates/ra_prof/src/lib.rs27
4 files changed, 17 insertions, 20 deletions
diff --git a/crates/ra_assists/Cargo.toml b/crates/ra_assists/Cargo.toml
index 29d9ceb59..5ddac1e48 100644
--- a/crates/ra_assists/Cargo.toml
+++ b/crates/ra_assists/Cargo.toml
@@ -5,7 +5,7 @@ version = "0.1.0"
5authors = ["rust-analyzer developers"] 5authors = ["rust-analyzer developers"]
6 6
7[dependencies] 7[dependencies]
8lazy_static = "1.3.0" 8once_cell = "0.2.0"
9join_to_string = "0.1.3" 9join_to_string = "0.1.3"
10itertools = "0.8.0" 10itertools = "0.8.0"
11arrayvec = "0.4.10" 11arrayvec = "0.4.10"
diff --git a/crates/ra_assists/src/ast_editor.rs b/crates/ra_assists/src/ast_editor.rs
index 726e5c0a3..aa7aeaabb 100644
--- a/crates/ra_assists/src/ast_editor.rs
+++ b/crates/ra_assists/src/ast_editor.rs
@@ -289,12 +289,10 @@ fn ast_node_from_file_text<N: AstNode>(text: &str) -> TreeArc<N> {
289} 289}
290 290
291mod tokens { 291mod tokens {
292 use lazy_static::lazy_static; 292 use once_cell::sync::Lazy;
293 use ra_syntax::{AstNode, SourceFile, TreeArc, SyntaxToken, SyntaxKind::*}; 293 use ra_syntax::{AstNode, SourceFile, TreeArc, SyntaxToken, SyntaxKind::*};
294 294
295 lazy_static! { 295 static SOURCE_FILE: Lazy<TreeArc<SourceFile>> = Lazy::new(|| SourceFile::parse(",\n; ;"));
296 static ref SOURCE_FILE: TreeArc<SourceFile> = SourceFile::parse(",\n; ;");
297 }
298 296
299 pub(crate) fn comma() -> SyntaxToken<'static> { 297 pub(crate) fn comma() -> SyntaxToken<'static> {
300 SOURCE_FILE 298 SOURCE_FILE
diff --git a/crates/ra_prof/Cargo.toml b/crates/ra_prof/Cargo.toml
index 19ce21783..5f23e865c 100644
--- a/crates/ra_prof/Cargo.toml
+++ b/crates/ra_prof/Cargo.toml
@@ -6,4 +6,4 @@ authors = ["rust-analyzer developers"]
6publish = false 6publish = false
7 7
8[dependencies] 8[dependencies]
9lazy_static = "1.3.0" \ No newline at end of file 9once_cell = "0.2.0"
diff --git a/crates/ra_prof/src/lib.rs b/crates/ra_prof/src/lib.rs
index 9ecb8e744..e56446c9f 100644
--- a/crates/ra_prof/src/lib.rs
+++ b/crates/ra_prof/src/lib.rs
@@ -1,13 +1,14 @@
1use std::cell::RefCell; 1use std::{
2use std::time::{Duration, Instant}; 2 cell::RefCell,
3use std::mem; 3 time::{Duration, Instant},
4use std::io::{stderr, Write}; 4 mem,
5use std::iter::repeat; 5 io::{stderr, Write},
6use std::collections::{HashSet}; 6 iter::repeat,
7use std::default::Default; 7 collections::HashSet,
8use std::iter::FromIterator; 8 sync::{RwLock, atomic::{AtomicBool, Ordering}},
9use std::sync::{RwLock, atomic::{AtomicBool, Ordering}}; 9};
10use lazy_static::lazy_static; 10
11use once_cell::sync::Lazy;
11 12
12/// Set profiling filter. It specifies descriptions allowed to profile. 13/// Set profiling filter. It specifies descriptions allowed to profile.
13/// This is helpful when call stack has too many nested profiling scopes. 14/// This is helpful when call stack has too many nested profiling scopes.
@@ -21,7 +22,7 @@ use lazy_static::lazy_static;
21/// ``` 22/// ```
22pub fn set_filter(f: Filter) { 23pub fn set_filter(f: Filter) {
23 PROFILING_ENABLED.store(f.depth > 0, Ordering::SeqCst); 24 PROFILING_ENABLED.store(f.depth > 0, Ordering::SeqCst);
24 let set = HashSet::from_iter(f.allowed.iter().cloned()); 25 let set: HashSet<_> = f.allowed.iter().cloned().collect();
25 let mut old = FILTER.write().unwrap(); 26 let mut old = FILTER.write().unwrap();
26 let filter_data = FilterData { 27 let filter_data = FilterData {
27 depth: f.depth, 28 depth: f.depth,
@@ -161,9 +162,7 @@ struct FilterData {
161 162
162static PROFILING_ENABLED: AtomicBool = AtomicBool::new(false); 163static PROFILING_ENABLED: AtomicBool = AtomicBool::new(false);
163 164
164lazy_static! { 165static FILTER: Lazy<RwLock<FilterData>> = Lazy::new(Default::default);
165 static ref FILTER: RwLock<FilterData> = RwLock::new(Default::default());
166}
167 166
168thread_local!(static PROFILE_STACK: RefCell<ProfileStack> = RefCell::new(ProfileStack::new())); 167thread_local!(static PROFILE_STACK: RefCell<ProfileStack> = RefCell::new(ProfileStack::new()));
169 168