diff options
Diffstat (limited to 'crates/ra_editor')
-rw-r--r-- | crates/ra_editor/Cargo.toml | 1 | ||||
-rw-r--r-- | crates/ra_editor/src/completion.rs | 8 | ||||
-rw-r--r-- | crates/ra_editor/src/folding_ranges.rs | 6 | ||||
-rw-r--r-- | crates/ra_editor/src/lib.rs | 1 | ||||
-rw-r--r-- | crates/ra_editor/src/scope/fn_scope.rs | 14 |
5 files changed, 15 insertions, 15 deletions
diff --git a/crates/ra_editor/Cargo.toml b/crates/ra_editor/Cargo.toml index 40e3254ff..91cefc8d7 100644 --- a/crates/ra_editor/Cargo.toml +++ b/crates/ra_editor/Cargo.toml | |||
@@ -8,6 +8,7 @@ publish = false | |||
8 | itertools = "0.7.8" | 8 | itertools = "0.7.8" |
9 | superslice = "0.1.0" | 9 | superslice = "0.1.0" |
10 | join_to_string = "0.1.1" | 10 | join_to_string = "0.1.1" |
11 | rustc-hash = "1.0" | ||
11 | 12 | ||
12 | ra_syntax = { path = "../ra_syntax" } | 13 | ra_syntax = { path = "../ra_syntax" } |
13 | 14 | ||
diff --git a/crates/ra_editor/src/completion.rs b/crates/ra_editor/src/completion.rs index 570d72d66..20b8484b3 100644 --- a/crates/ra_editor/src/completion.rs +++ b/crates/ra_editor/src/completion.rs | |||
@@ -1,4 +1,4 @@ | |||
1 | use std::collections::{HashSet, HashMap}; | 1 | use rustc_hash::{FxHashMap, FxHashSet}; |
2 | 2 | ||
3 | use ra_syntax::{ | 3 | use ra_syntax::{ |
4 | File, TextUnit, AstNode, SyntaxNodeRef, SyntaxKind::*, | 4 | File, TextUnit, AstNode, SyntaxNodeRef, SyntaxKind::*, |
@@ -96,7 +96,7 @@ fn complete_name_ref(file: &File, name_ref: ast::NameRef, acc: &mut Vec<Completi | |||
96 | } | 96 | } |
97 | 97 | ||
98 | fn param_completions(ctx: SyntaxNodeRef, acc: &mut Vec<CompletionItem>) { | 98 | fn param_completions(ctx: SyntaxNodeRef, acc: &mut Vec<CompletionItem>) { |
99 | let mut params = HashMap::new(); | 99 | let mut params = FxHashMap::default(); |
100 | for node in ctx.ancestors() { | 100 | for node in ctx.ancestors() { |
101 | let _ = visitor_ctx(&mut params) | 101 | let _ = visitor_ctx(&mut params) |
102 | .visit::<ast::Root, _>(process) | 102 | .visit::<ast::Root, _>(process) |
@@ -114,7 +114,7 @@ fn param_completions(ctx: SyntaxNodeRef, acc: &mut Vec<CompletionItem>) { | |||
114 | }) | 114 | }) |
115 | }); | 115 | }); |
116 | 116 | ||
117 | fn process<'a, N: ast::FnDefOwner<'a>>(node: N, params: &mut HashMap<String, (u32, ast::Param<'a>)>) { | 117 | fn process<'a, N: ast::FnDefOwner<'a>>(node: N, params: &mut FxHashMap<String, (u32, ast::Param<'a>)>) { |
118 | node.functions() | 118 | node.functions() |
119 | .filter_map(|it| it.param_list()) | 119 | .filter_map(|it| it.param_list()) |
120 | .flat_map(|it| it.params()) | 120 | .flat_map(|it| it.params()) |
@@ -232,7 +232,7 @@ fn complete_mod_item_snippets(acc: &mut Vec<CompletionItem>) { | |||
232 | } | 232 | } |
233 | 233 | ||
234 | fn complete_fn(name_ref: ast::NameRef, scopes: &FnScopes, acc: &mut Vec<CompletionItem>) { | 234 | fn complete_fn(name_ref: ast::NameRef, scopes: &FnScopes, acc: &mut Vec<CompletionItem>) { |
235 | let mut shadowed = HashSet::new(); | 235 | let mut shadowed = FxHashSet::default(); |
236 | acc.extend( | 236 | acc.extend( |
237 | scopes.scope_chain(name_ref.syntax()) | 237 | scopes.scope_chain(name_ref.syntax()) |
238 | .flat_map(|scope| scopes.entries(scope).iter()) | 238 | .flat_map(|scope| scopes.entries(scope).iter()) |
diff --git a/crates/ra_editor/src/folding_ranges.rs b/crates/ra_editor/src/folding_ranges.rs index 733512368..3aabd54ae 100644 --- a/crates/ra_editor/src/folding_ranges.rs +++ b/crates/ra_editor/src/folding_ranges.rs | |||
@@ -1,4 +1,4 @@ | |||
1 | use std::collections::HashSet; | 1 | use rustc_hash::FxHashSet; |
2 | 2 | ||
3 | use ra_syntax::{ | 3 | use ra_syntax::{ |
4 | File, TextRange, SyntaxNodeRef, | 4 | File, TextRange, SyntaxNodeRef, |
@@ -20,7 +20,7 @@ pub struct Fold { | |||
20 | 20 | ||
21 | pub fn folding_ranges(file: &File) -> Vec<Fold> { | 21 | pub fn folding_ranges(file: &File) -> Vec<Fold> { |
22 | let mut res = vec![]; | 22 | let mut res = vec![]; |
23 | let mut visited = HashSet::new(); | 23 | let mut visited = FxHashSet::default(); |
24 | 24 | ||
25 | for node in file.syntax().descendants() { | 25 | for node in file.syntax().descendants() { |
26 | if visited.contains(&node) { | 26 | if visited.contains(&node) { |
@@ -56,7 +56,7 @@ pub fn folding_ranges(file: &File) -> Vec<Fold> { | |||
56 | fn contiguous_range_for<'a>( | 56 | fn contiguous_range_for<'a>( |
57 | kind: SyntaxKind, | 57 | kind: SyntaxKind, |
58 | node: SyntaxNodeRef<'a>, | 58 | node: SyntaxNodeRef<'a>, |
59 | visited: &mut HashSet<SyntaxNodeRef<'a>>, | 59 | visited: &mut FxHashSet<SyntaxNodeRef<'a>>, |
60 | ) -> Option<TextRange> { | 60 | ) -> Option<TextRange> { |
61 | visited.insert(node); | 61 | visited.insert(node); |
62 | 62 | ||
diff --git a/crates/ra_editor/src/lib.rs b/crates/ra_editor/src/lib.rs index 906ee11fe..710afc65d 100644 --- a/crates/ra_editor/src/lib.rs +++ b/crates/ra_editor/src/lib.rs | |||
@@ -2,6 +2,7 @@ extern crate ra_syntax; | |||
2 | extern crate superslice; | 2 | extern crate superslice; |
3 | extern crate itertools; | 3 | extern crate itertools; |
4 | extern crate join_to_string; | 4 | extern crate join_to_string; |
5 | extern crate rustc_hash; | ||
5 | #[cfg(test)] | 6 | #[cfg(test)] |
6 | #[macro_use] | 7 | #[macro_use] |
7 | extern crate test_utils as _test_utils; | 8 | extern crate test_utils as _test_utils; |
diff --git a/crates/ra_editor/src/scope/fn_scope.rs b/crates/ra_editor/src/scope/fn_scope.rs index 65d85279f..9a48bda02 100644 --- a/crates/ra_editor/src/scope/fn_scope.rs +++ b/crates/ra_editor/src/scope/fn_scope.rs | |||
@@ -1,7 +1,5 @@ | |||
1 | use std::{ | 1 | use std::fmt; |
2 | fmt, | 2 | use rustc_hash::FxHashMap; |
3 | collections::HashMap, | ||
4 | }; | ||
5 | 3 | ||
6 | use ra_syntax::{ | 4 | use ra_syntax::{ |
7 | SyntaxNodeRef, SyntaxNode, SmolStr, AstNode, | 5 | SyntaxNodeRef, SyntaxNode, SmolStr, AstNode, |
@@ -15,7 +13,7 @@ type ScopeId = usize; | |||
15 | pub struct FnScopes { | 13 | pub struct FnScopes { |
16 | pub self_param: Option<SyntaxNode>, | 14 | pub self_param: Option<SyntaxNode>, |
17 | scopes: Vec<ScopeData>, | 15 | scopes: Vec<ScopeData>, |
18 | scope_for: HashMap<SyntaxNode, ScopeId>, | 16 | scope_for: FxHashMap<SyntaxNode, ScopeId>, |
19 | } | 17 | } |
20 | 18 | ||
21 | impl FnScopes { | 19 | impl FnScopes { |
@@ -25,7 +23,7 @@ impl FnScopes { | |||
25 | .and_then(|it| it.self_param()) | 23 | .and_then(|it| it.self_param()) |
26 | .map(|it| it.syntax().owned()), | 24 | .map(|it| it.syntax().owned()), |
27 | scopes: Vec::new(), | 25 | scopes: Vec::new(), |
28 | scope_for: HashMap::new() | 26 | scope_for: FxHashMap::default() |
29 | }; | 27 | }; |
30 | let root = scopes.root_scope(); | 28 | let root = scopes.root_scope(); |
31 | scopes.add_params_bindings(root, fn_def.param_list()); | 29 | scopes.add_params_bindings(root, fn_def.param_list()); |
@@ -242,9 +240,9 @@ struct ScopeData { | |||
242 | } | 240 | } |
243 | 241 | ||
244 | pub fn resolve_local_name<'a>(name_ref: ast::NameRef, scopes: &'a FnScopes) -> Option<&'a ScopeEntry> { | 242 | pub fn resolve_local_name<'a>(name_ref: ast::NameRef, scopes: &'a FnScopes) -> Option<&'a ScopeEntry> { |
245 | use std::collections::HashSet; | 243 | use rustc_hash::FxHashSet; |
246 | 244 | ||
247 | let mut shadowed = HashSet::new(); | 245 | let mut shadowed = FxHashSet::default(); |
248 | let ret = scopes.scope_chain(name_ref.syntax()) | 246 | let ret = scopes.scope_chain(name_ref.syntax()) |
249 | .flat_map(|scope| scopes.entries(scope).iter()) | 247 | .flat_map(|scope| scopes.entries(scope).iter()) |
250 | .filter(|entry| shadowed.insert(entry.name())) | 248 | .filter(|entry| shadowed.insert(entry.name())) |