aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--Cargo.lock20
-rw-r--r--crates/ra_ide/Cargo.toml4
-rw-r--r--crates/ra_ide_db/Cargo.toml1
-rw-r--r--crates/ra_ide_db/src/symbol_index.rs20
5 files changed, 14 insertions, 32 deletions
diff --git a/.gitignore b/.gitignore
index 99e0c5003..dc5ceca7f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -6,3 +6,4 @@ crates/*/target
6*.log 6*.log
7*.iml 7*.iml
8.vscode/settings.json 8.vscode/settings.json
9cargo-timing*.html
diff --git a/Cargo.lock b/Cargo.lock
index c10d72aa4..e7b873076 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1043,7 +1043,6 @@ version = "0.1.0"
1043dependencies = [ 1043dependencies = [
1044 "either", 1044 "either",
1045 "format-buf", 1045 "format-buf",
1046 "fst",
1047 "indexmap", 1046 "indexmap",
1048 "insta", 1047 "insta",
1049 "itertools", 1048 "itertools",
@@ -1060,11 +1059,8 @@ dependencies = [
1060 "ra_syntax", 1059 "ra_syntax",
1061 "ra_text_edit", 1060 "ra_text_edit",
1062 "rand", 1061 "rand",
1063 "rayon",
1064 "rustc-hash", 1062 "rustc-hash",
1065 "superslice",
1066 "test_utils", 1063 "test_utils",
1067 "unicase",
1068] 1064]
1069 1065
1070[[package]] 1066[[package]]
@@ -1091,7 +1087,6 @@ dependencies = [
1091 "rustc-hash", 1087 "rustc-hash",
1092 "superslice", 1088 "superslice",
1093 "test_utils", 1089 "test_utils",
1094 "unicase",
1095] 1090]
1096 1091
1097[[package]] 1092[[package]]
@@ -1603,15 +1598,6 @@ dependencies = [
1603] 1598]
1604 1599
1605[[package]] 1600[[package]]
1606name = "unicase"
1607version = "2.6.0"
1608source = "registry+https://github.com/rust-lang/crates.io-index"
1609checksum = "50f37be617794602aabbeee0be4f259dc1778fabe05e2d67ee8f79326d5cb4f6"
1610dependencies = [
1611 "version_check",
1612]
1613
1614[[package]]
1615name = "unicode-bidi" 1601name = "unicode-bidi"
1616version = "0.3.4" 1602version = "0.3.4"
1617source = "registry+https://github.com/rust-lang/crates.io-index" 1603source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1654,12 +1640,6 @@ dependencies = [
1654] 1640]
1655 1641
1656[[package]] 1642[[package]]
1657name = "version_check"
1658version = "0.9.1"
1659source = "registry+https://github.com/rust-lang/crates.io-index"
1660checksum = "078775d0255232fb988e6fccf26ddc9d1ac274299aaedcedce21c6f72cc533ce"
1661
1662[[package]]
1663name = "walkdir" 1643name = "walkdir"
1664version = "2.3.1" 1644version = "2.3.1"
1665source = "registry+https://github.com/rust-lang/crates.io-index" 1645source = "registry+https://github.com/rust-lang/crates.io-index"
diff --git a/crates/ra_ide/Cargo.toml b/crates/ra_ide/Cargo.toml
index d50cf1d20..97dea5ffd 100644
--- a/crates/ra_ide/Cargo.toml
+++ b/crates/ra_ide/Cargo.toml
@@ -17,11 +17,7 @@ indexmap = "1.3.0"
17itertools = "0.8.0" 17itertools = "0.8.0"
18join_to_string = "0.1.3" 18join_to_string = "0.1.3"
19log = "0.4.5" 19log = "0.4.5"
20rayon = "1.0.2"
21fst = { version = "0.3.1", default-features = false }
22rustc-hash = "1.0" 20rustc-hash = "1.0"
23unicase = "2.2.0"
24superslice = "1.0.0"
25rand = { version = "0.7.0", features = ["small_rng"] } 21rand = { version = "0.7.0", features = ["small_rng"] }
26once_cell = "1.2.0" 22once_cell = "1.2.0"
27 23
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();