aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2020-02-18 13:39:24 +0000
committerAleksey Kladov <[email protected]>2020-02-18 13:44:52 +0000
commit039f2039a4ec06c8e52734190ceaf43a21de5e39 (patch)
tree5e34d8f684d35cf4e01d7f2b483ac242cfee7cb2
parentb643ccfaeda59f642a19d87e780976b3536d7b33 (diff)
Remove unicase dependency
-rw-r--r--Cargo.lock16
-rw-r--r--crates/ra_ide_db/Cargo.toml1
-rw-r--r--crates/ra_ide_db/src/symbol_index.rs20
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]]
1602name = "unicase"
1603version = "2.6.0"
1604source = "registry+https://github.com/rust-lang/crates.io-index"
1605checksum = "50f37be617794602aabbeee0be4f259dc1778fabe05e2d67ee8f79326d5cb4f6"
1606dependencies = [
1607 "version_check",
1608]
1609
1610[[package]]
1611name = "unicode-bidi" 1601name = "unicode-bidi"
1612version = "0.3.4" 1602version = "0.3.4"
1613source = "registry+https://github.com/rust-lang/crates.io-index" 1603source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1650,12 +1640,6 @@ dependencies = [
1650] 1640]
1651 1641
1652[[package]] 1642[[package]]
1653name = "version_check"
1654version = "0.9.1"
1655source = "registry+https://github.com/rust-lang/crates.io-index"
1656checksum = "078775d0255232fb988e6fccf26ddc9d1ac274299aaedcedce21c6f72cc533ce"
1657
1658[[package]]
1659name = "walkdir" 1643name = "walkdir"
1660version = "2.3.1" 1644version = "2.3.1"
1661source = "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_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();