diff options
-rw-r--r-- | Cargo.lock | 16 | ||||
-rw-r--r-- | crates/ra_ide_db/Cargo.toml | 1 | ||||
-rw-r--r-- | crates/ra_ide_db/src/symbol_index.rs | 20 |
3 files changed, 13 insertions, 24 deletions
diff --git a/Cargo.lock b/Cargo.lock index 872e66118..e7b873076 100644 --- a/Cargo.lock +++ b/Cargo.lock | |||
@@ -1087,7 +1087,6 @@ dependencies = [ | |||
1087 | "rustc-hash", | 1087 | "rustc-hash", |
1088 | "superslice", | 1088 | "superslice", |
1089 | "test_utils", | 1089 | "test_utils", |
1090 | "unicase", | ||
1091 | ] | 1090 | ] |
1092 | 1091 | ||
1093 | [[package]] | 1092 | [[package]] |
@@ -1599,15 +1598,6 @@ dependencies = [ | |||
1599 | ] | 1598 | ] |
1600 | 1599 | ||
1601 | [[package]] | 1600 | [[package]] |
1602 | name = "unicase" | ||
1603 | version = "2.6.0" | ||
1604 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
1605 | checksum = "50f37be617794602aabbeee0be4f259dc1778fabe05e2d67ee8f79326d5cb4f6" | ||
1606 | dependencies = [ | ||
1607 | "version_check", | ||
1608 | ] | ||
1609 | |||
1610 | [[package]] | ||
1611 | name = "unicode-bidi" | 1601 | name = "unicode-bidi" |
1612 | version = "0.3.4" | 1602 | version = "0.3.4" |
1613 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1603 | source = "registry+https://github.com/rust-lang/crates.io-index" |
@@ -1650,12 +1640,6 @@ dependencies = [ | |||
1650 | ] | 1640 | ] |
1651 | 1641 | ||
1652 | [[package]] | 1642 | [[package]] |
1653 | name = "version_check" | ||
1654 | version = "0.9.1" | ||
1655 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
1656 | checksum = "078775d0255232fb988e6fccf26ddc9d1ac274299aaedcedce21c6f72cc533ce" | ||
1657 | |||
1658 | [[package]] | ||
1659 | name = "walkdir" | 1643 | name = "walkdir" |
1660 | version = "2.3.1" | 1644 | version = "2.3.1" |
1661 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1645 | source = "registry+https://github.com/rust-lang/crates.io-index" |
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" | |||
20 | rayon = "1.0.2" | 20 | rayon = "1.0.2" |
21 | fst = { version = "0.3.1", default-features = false } | 21 | fst = { version = "0.3.1", default-features = false } |
22 | rustc-hash = "1.0" | 22 | rustc-hash = "1.0" |
23 | unicase = "2.2.0" | ||
24 | superslice = "1.0.0" | 23 | superslice = "1.0.0" |
25 | once_cell = "1.2.0" | 24 | once_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 | ||
23 | use std::{ | 23 | use 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 | ||
188 | impl SymbolIndex { | 189 | impl 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(); |