aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide_db
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_ide_db')
-rw-r--r--crates/ra_ide_db/Cargo.toml1
-rw-r--r--crates/ra_ide_db/src/symbol_index.rs20
2 files changed, 13 insertions, 8 deletions
diff --git a/crates/ra_ide_db/Cargo.toml b/crates/ra_ide_db/Cargo.toml
index ad3acce59..dbe98f3a0 100644
--- a/crates/ra_ide_db/Cargo.toml
+++ b/crates/ra_ide_db/Cargo.toml
@@ -20,7 +20,6 @@ log = "0.4.5"
20rayon = "1.0.2" 20rayon = "1.0.2"
21fst = { version = "0.3.1", default-features = false } 21fst = { version = "0.3.1", default-features = false }
22rustc-hash = "1.0" 22rustc-hash = "1.0"
23unicase = "2.2.0"
24superslice = "1.0.0" 23superslice = "1.0.0"
25once_cell = "1.2.0" 24once_cell = "1.2.0"
26 25
diff --git a/crates/ra_ide_db/src/symbol_index.rs b/crates/ra_ide_db/src/symbol_index.rs
index 64ddf2f95..e6b3126b6 100644
--- a/crates/ra_ide_db/src/symbol_index.rs
+++ b/crates/ra_ide_db/src/symbol_index.rs
@@ -21,6 +21,7 @@
21//! those FSTs. 21//! those FSTs.
22 22
23use std::{ 23use std::{
24 cmp::Ordering,
24 fmt, 25 fmt,
25 hash::{Hash, Hasher}, 26 hash::{Hash, Hasher},
26 mem, 27 mem,
@@ -187,29 +188,34 @@ impl Hash for SymbolIndex {
187 188
188impl SymbolIndex { 189impl SymbolIndex {
189 fn new(mut symbols: Vec<FileSymbol>) -> SymbolIndex { 190 fn new(mut symbols: Vec<FileSymbol>) -> SymbolIndex {
190 fn cmp_key<'a>(s1: &'a FileSymbol) -> impl Ord + 'a { 191 fn cmp(lhs: &FileSymbol, rhs: &FileSymbol) -> Ordering {
191 unicase::Ascii::new(s1.name.as_str()) 192 let lhs_chars = lhs.name.chars().map(|c| c.to_ascii_lowercase());
193 let rhs_chars = rhs.name.chars().map(|c| c.to_ascii_lowercase());
194 lhs_chars.cmp(rhs_chars)
192 } 195 }
196
193 #[cfg(not(feature = "wasm"))] 197 #[cfg(not(feature = "wasm"))]
194 symbols.par_sort_by(|s1, s2| cmp_key(s1).cmp(&cmp_key(s2))); 198 symbols.par_sort_by(cmp);
195 199
196 #[cfg(feature = "wasm")] 200 #[cfg(feature = "wasm")]
197 symbols.sort_by(|s1, s2| cmp_key(s1).cmp(&cmp_key(s2))); 201 symbols.sort_by(cmp);
198 202
199 let mut builder = fst::MapBuilder::memory(); 203 let mut builder = fst::MapBuilder::memory();
200 204
201 let mut last_batch_start = 0; 205 let mut last_batch_start = 0;
202 206
203 for idx in 0..symbols.len() { 207 for idx in 0..symbols.len() {
204 if symbols.get(last_batch_start).map(cmp_key) == symbols.get(idx + 1).map(cmp_key) { 208 if let Some(next_symbol) = symbols.get(idx + 1) {
205 continue; 209 if cmp(&symbols[last_batch_start], next_symbol) == Ordering::Equal {
210 continue;
211 }
206 } 212 }
207 213
208 let start = last_batch_start; 214 let start = last_batch_start;
209 let end = idx + 1; 215 let end = idx + 1;
210 last_batch_start = end; 216 last_batch_start = end;
211 217
212 let key = symbols[start].name.as_str().to_lowercase(); 218 let key = symbols[start].name.as_str().to_ascii_lowercase();
213 let value = SymbolIndex::range_to_map_value(start, end); 219 let value = SymbolIndex::range_to_map_value(start, end);
214 220
215 builder.insert(key, value).unwrap(); 221 builder.insert(key, value).unwrap();