aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_analysis
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_analysis')
-rw-r--r--crates/ra_analysis/Cargo.toml1
-rw-r--r--crates/ra_analysis/src/db/imp.rs9
-rw-r--r--crates/ra_analysis/src/imp.rs7
-rw-r--r--crates/ra_analysis/src/lib.rs5
-rw-r--r--crates/ra_analysis/src/roots.rs6
-rw-r--r--crates/ra_analysis/tests/tests.rs5
6 files changed, 19 insertions, 14 deletions
diff --git a/crates/ra_analysis/Cargo.toml b/crates/ra_analysis/Cargo.toml
index a30cdfc9c..a82e1761c 100644
--- a/crates/ra_analysis/Cargo.toml
+++ b/crates/ra_analysis/Cargo.toml
@@ -15,6 +15,7 @@ im = "12.0.0"
15ra_syntax = { path = "../ra_syntax" } 15ra_syntax = { path = "../ra_syntax" }
16ra_editor = { path = "../ra_editor" } 16ra_editor = { path = "../ra_editor" }
17salsa = { path = "../salsa" } 17salsa = { path = "../salsa" }
18rustc-hash = "1.0"
18 19
19[dev-dependencies] 20[dev-dependencies]
20test_utils = { path = "../test_utils" } 21test_utils = { path = "../test_utils" }
diff --git a/crates/ra_analysis/src/db/imp.rs b/crates/ra_analysis/src/db/imp.rs
index f26be1046..36f6cf290 100644
--- a/crates/ra_analysis/src/db/imp.rs
+++ b/crates/ra_analysis/src/db/imp.rs
@@ -2,9 +2,10 @@ use std::{
2 sync::Arc, 2 sync::Arc,
3 any::Any, 3 any::Any,
4 hash::{Hash, Hasher}, 4 hash::{Hash, Hasher},
5 collections::hash_map::{DefaultHasher, HashMap}, 5 collections::hash_map::{DefaultHasher},
6 iter, 6 iter,
7}; 7};
8use rustc_hash::FxHashMap;
8use salsa; 9use salsa;
9use {FileId, imp::FileResolverImp}; 10use {FileId, imp::FileResolverImp};
10use super::{State, Query, QueryCtx}; 11use super::{State, Query, QueryCtx};
@@ -13,7 +14,7 @@ pub(super) type Data = Arc<Any + Send + Sync + 'static>;
13 14
14#[derive(Debug)] 15#[derive(Debug)]
15pub(super) struct Db { 16pub(super) struct Db {
16 names: Arc<HashMap<salsa::QueryTypeId, &'static str>>, 17 names: Arc<FxHashMap<salsa::QueryTypeId, &'static str>>,
17 pub(super) imp: salsa::Db<State, Data>, 18 pub(super) imp: salsa::Db<State, Data>,
18} 19}
19 20
@@ -85,7 +86,7 @@ where
85 86
86pub(super) struct QueryRegistry { 87pub(super) struct QueryRegistry {
87 config: Option<salsa::QueryConfig<State, Data>>, 88 config: Option<salsa::QueryConfig<State, Data>>,
88 names: HashMap<salsa::QueryTypeId, &'static str>, 89 names: FxHashMap<salsa::QueryTypeId, &'static str>,
89} 90}
90 91
91impl QueryRegistry { 92impl QueryRegistry {
@@ -109,7 +110,7 @@ impl QueryRegistry {
109 (Arc::new(res), fingerprint) 110 (Arc::new(res), fingerprint)
110 }) 111 })
111 ); 112 );
112 let mut names = HashMap::new(); 113 let mut names = FxHashMap::default();
113 names.insert(FILE_TEXT, "FILE_TEXT"); 114 names.insert(FILE_TEXT, "FILE_TEXT");
114 names.insert(FILE_SET, "FILE_SET"); 115 names.insert(FILE_SET, "FILE_SET");
115 QueryRegistry { config: Some(config), names } 116 QueryRegistry { config: Some(config), names }
diff --git a/crates/ra_analysis/src/imp.rs b/crates/ra_analysis/src/imp.rs
index 517867e86..47bc0032b 100644
--- a/crates/ra_analysis/src/imp.rs
+++ b/crates/ra_analysis/src/imp.rs
@@ -4,11 +4,12 @@ use std::{
4 atomic::{AtomicBool, Ordering::SeqCst}, 4 atomic::{AtomicBool, Ordering::SeqCst},
5 }, 5 },
6 fmt, 6 fmt,
7 collections::{HashSet, VecDeque}, 7 collections::VecDeque,
8 iter, 8 iter,
9}; 9};
10 10
11use relative_path::RelativePath; 11use relative_path::RelativePath;
12use rustc_hash::FxHashSet;
12use ra_editor::{self, FileSymbol, LineIndex, find_node_at_offset, LocalEdit, resolve_local_name}; 13use ra_editor::{self, FileSymbol, LineIndex, find_node_at_offset, LocalEdit, resolve_local_name};
13use ra_syntax::{ 14use ra_syntax::{
14 TextUnit, TextRange, SmolStr, File, AstNode, 15 TextUnit, TextRange, SmolStr, File, AstNode,
@@ -84,7 +85,7 @@ impl AnalysisHostImpl {
84 data.root = Arc::new(data.root.apply_changes(&mut iter::empty(), Some(resolver))); 85 data.root = Arc::new(data.root.apply_changes(&mut iter::empty(), Some(resolver)));
85 } 86 }
86 pub fn set_crate_graph(&mut self, graph: CrateGraph) { 87 pub fn set_crate_graph(&mut self, graph: CrateGraph) {
87 let mut visited = HashSet::new(); 88 let mut visited = FxHashSet::default();
88 for &file_id in graph.crate_roots.values() { 89 for &file_id in graph.crate_roots.values() {
89 if !visited.insert(file_id) { 90 if !visited.insert(file_id) {
90 panic!("duplicate crate root: {:?}", file_id); 91 panic!("duplicate crate root: {:?}", file_id);
@@ -168,7 +169,7 @@ impl AnalysisImpl {
168 let mut res = Vec::new(); 169 let mut res = Vec::new();
169 let mut work = VecDeque::new(); 170 let mut work = VecDeque::new();
170 work.push_back(file_id); 171 work.push_back(file_id);
171 let mut visited = HashSet::new(); 172 let mut visited = FxHashSet::default();
172 while let Some(id) = work.pop_front() { 173 while let Some(id) = work.pop_front() {
173 if let Some(crate_id) = crate_graph.crate_id_for_crate_root(id) { 174 if let Some(crate_id) = crate_graph.crate_id_for_crate_root(id) {
174 res.push(crate_id); 175 res.push(crate_id);
diff --git a/crates/ra_analysis/src/lib.rs b/crates/ra_analysis/src/lib.rs
index f6ceb7eb2..849fd93e4 100644
--- a/crates/ra_analysis/src/lib.rs
+++ b/crates/ra_analysis/src/lib.rs
@@ -11,6 +11,7 @@ extern crate relative_path;
11extern crate crossbeam_channel; 11extern crate crossbeam_channel;
12extern crate im; 12extern crate im;
13extern crate salsa; 13extern crate salsa;
14extern crate rustc_hash;
14 15
15mod symbol_index; 16mod symbol_index;
16mod module_map; 17mod module_map;
@@ -23,13 +24,13 @@ mod descriptors;
23 24
24use std::{ 25use std::{
25 sync::Arc, 26 sync::Arc,
26 collections::HashMap,
27 fmt::Debug, 27 fmt::Debug,
28}; 28};
29 29
30use relative_path::{RelativePath, RelativePathBuf}; 30use relative_path::{RelativePath, RelativePathBuf};
31use ra_syntax::{File, TextRange, TextUnit, AtomEdit}; 31use ra_syntax::{File, TextRange, TextUnit, AtomEdit};
32use imp::{AnalysisImpl, AnalysisHostImpl, FileResolverImp}; 32use imp::{AnalysisImpl, AnalysisHostImpl, FileResolverImp};
33use rustc_hash::FxHashMap;
33 34
34pub use ra_editor::{ 35pub use ra_editor::{
35 StructureNode, LineIndex, FileSymbol, 36 StructureNode, LineIndex, FileSymbol,
@@ -46,7 +47,7 @@ pub struct CrateId(pub u32);
46 47
47#[derive(Debug, Clone, Default)] 48#[derive(Debug, Clone, Default)]
48pub struct CrateGraph { 49pub struct CrateGraph {
49 pub crate_roots: HashMap<CrateId, FileId>, 50 pub crate_roots: FxHashMap<CrateId, FileId>,
50} 51}
51 52
52pub trait FileResolver: Debug + Send + Sync + 'static { 53pub trait FileResolver: Debug + Send + Sync + 'static {
diff --git a/crates/ra_analysis/src/roots.rs b/crates/ra_analysis/src/roots.rs
index 1835a9b25..32a8c5bd0 100644
--- a/crates/ra_analysis/src/roots.rs
+++ b/crates/ra_analysis/src/roots.rs
@@ -1,11 +1,11 @@
1use std::{ 1use std::{
2 collections::HashMap,
3 sync::Arc, 2 sync::Arc,
4 panic, 3 panic,
5}; 4};
6 5
7use once_cell::sync::OnceCell; 6use once_cell::sync::OnceCell;
8use rayon::prelude::*; 7use rayon::prelude::*;
8use rustc_hash::FxHashMap;
9use ra_editor::LineIndex; 9use ra_editor::LineIndex;
10use ra_syntax::File; 10use ra_syntax::File;
11 11
@@ -118,7 +118,7 @@ impl FileData {
118#[derive(Debug)] 118#[derive(Debug)]
119pub(crate) struct ReadonlySourceRoot { 119pub(crate) struct ReadonlySourceRoot {
120 symbol_index: Arc<SymbolIndex>, 120 symbol_index: Arc<SymbolIndex>,
121 file_map: HashMap<FileId, FileData>, 121 file_map: FxHashMap<FileId, FileData>,
122 module_tree: Arc<ModuleTreeDescriptor>, 122 module_tree: Arc<ModuleTreeDescriptor>,
123} 123}
124 124
@@ -139,7 +139,7 @@ impl ReadonlySourceRoot {
139 let symbol_index = SymbolIndex::for_files( 139 let symbol_index = SymbolIndex::for_files(
140 modules.par_iter().map(|it| (it.0, it.1.clone())) 140 modules.par_iter().map(|it| (it.0, it.1.clone()))
141 ); 141 );
142 let file_map: HashMap<FileId, FileData> = files 142 let file_map: FxHashMap<FileId, FileData> = files
143 .into_iter() 143 .into_iter()
144 .map(|(id, text)| (id, FileData::new(text))) 144 .map(|(id, text)| (id, FileData::new(text)))
145 .collect(); 145 .collect();
diff --git a/crates/ra_analysis/tests/tests.rs b/crates/ra_analysis/tests/tests.rs
index 334dc5e48..a886cd0ff 100644
--- a/crates/ra_analysis/tests/tests.rs
+++ b/crates/ra_analysis/tests/tests.rs
@@ -1,12 +1,13 @@
1extern crate relative_path; 1extern crate relative_path;
2extern crate ra_analysis; 2extern crate ra_analysis;
3extern crate rustc_hash;
3extern crate test_utils; 4extern crate test_utils;
4 5
5use std::{ 6use std::{
6 sync::Arc, 7 sync::Arc,
7 collections::HashMap,
8}; 8};
9 9
10use rustc_hash::FxHashMap;
10use relative_path::{RelativePath, RelativePathBuf}; 11use relative_path::{RelativePath, RelativePathBuf};
11use ra_analysis::{Analysis, AnalysisHost, FileId, FileResolver, JobHandle, CrateGraph, CrateId}; 12use ra_analysis::{Analysis, AnalysisHost, FileId, FileResolver, JobHandle, CrateGraph, CrateId};
12use test_utils::assert_eq_dbg; 13use test_utils::assert_eq_dbg;
@@ -131,7 +132,7 @@ fn test_resolve_crate_root() {
131 132
132 let crate_graph = CrateGraph { 133 let crate_graph = CrateGraph {
133 crate_roots: { 134 crate_roots: {
134 let mut m = HashMap::new(); 135 let mut m = FxHashMap::default();
135 m.insert(CrateId(1), FileId(1)); 136 m.insert(CrateId(1), FileId(1));
136 m 137 m
137 }, 138 },