mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-13 13:48:50 +00:00
Remove unicase dependency
This commit is contained in:
parent
b643ccfaed
commit
039f2039a4
3 changed files with 13 additions and 24 deletions
16
Cargo.lock
generated
16
Cargo.lock
generated
|
@ -1087,7 +1087,6 @@ dependencies = [
|
||||||
"rustc-hash",
|
"rustc-hash",
|
||||||
"superslice",
|
"superslice",
|
||||||
"test_utils",
|
"test_utils",
|
||||||
"unicase",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -1598,15 +1597,6 @@ dependencies = [
|
||||||
"num_cpus",
|
"num_cpus",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "unicase"
|
|
||||||
version = "2.6.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "50f37be617794602aabbeee0be4f259dc1778fabe05e2d67ee8f79326d5cb4f6"
|
|
||||||
dependencies = [
|
|
||||||
"version_check",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "unicode-bidi"
|
name = "unicode-bidi"
|
||||||
version = "0.3.4"
|
version = "0.3.4"
|
||||||
|
@ -1649,12 +1639,6 @@ dependencies = [
|
||||||
"serde",
|
"serde",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "version_check"
|
|
||||||
version = "0.9.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "078775d0255232fb988e6fccf26ddc9d1ac274299aaedcedce21c6f72cc533ce"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "walkdir"
|
name = "walkdir"
|
||||||
version = "2.3.1"
|
version = "2.3.1"
|
||||||
|
|
|
@ -20,7 +20,6 @@ log = "0.4.5"
|
||||||
rayon = "1.0.2"
|
rayon = "1.0.2"
|
||||||
fst = { version = "0.3.1", default-features = false }
|
fst = { version = "0.3.1", default-features = false }
|
||||||
rustc-hash = "1.0"
|
rustc-hash = "1.0"
|
||||||
unicase = "2.2.0"
|
|
||||||
superslice = "1.0.0"
|
superslice = "1.0.0"
|
||||||
once_cell = "1.2.0"
|
once_cell = "1.2.0"
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
//! those FSTs.
|
//! those FSTs.
|
||||||
|
|
||||||
use std::{
|
use std::{
|
||||||
|
cmp::Ordering,
|
||||||
fmt,
|
fmt,
|
||||||
hash::{Hash, Hasher},
|
hash::{Hash, Hasher},
|
||||||
mem,
|
mem,
|
||||||
|
@ -187,29 +188,34 @@ impl Hash for SymbolIndex {
|
||||||
|
|
||||||
impl SymbolIndex {
|
impl SymbolIndex {
|
||||||
fn new(mut symbols: Vec<FileSymbol>) -> SymbolIndex {
|
fn new(mut symbols: Vec<FileSymbol>) -> SymbolIndex {
|
||||||
fn cmp_key<'a>(s1: &'a FileSymbol) -> impl Ord + 'a {
|
fn cmp(lhs: &FileSymbol, rhs: &FileSymbol) -> Ordering {
|
||||||
unicase::Ascii::new(s1.name.as_str())
|
let lhs_chars = lhs.name.chars().map(|c| c.to_ascii_lowercase());
|
||||||
|
let rhs_chars = rhs.name.chars().map(|c| c.to_ascii_lowercase());
|
||||||
|
lhs_chars.cmp(rhs_chars)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(feature = "wasm"))]
|
#[cfg(not(feature = "wasm"))]
|
||||||
symbols.par_sort_by(|s1, s2| cmp_key(s1).cmp(&cmp_key(s2)));
|
symbols.par_sort_by(cmp);
|
||||||
|
|
||||||
#[cfg(feature = "wasm")]
|
#[cfg(feature = "wasm")]
|
||||||
symbols.sort_by(|s1, s2| cmp_key(s1).cmp(&cmp_key(s2)));
|
symbols.sort_by(cmp);
|
||||||
|
|
||||||
let mut builder = fst::MapBuilder::memory();
|
let mut builder = fst::MapBuilder::memory();
|
||||||
|
|
||||||
let mut last_batch_start = 0;
|
let mut last_batch_start = 0;
|
||||||
|
|
||||||
for idx in 0..symbols.len() {
|
for idx in 0..symbols.len() {
|
||||||
if symbols.get(last_batch_start).map(cmp_key) == symbols.get(idx + 1).map(cmp_key) {
|
if let Some(next_symbol) = symbols.get(idx + 1) {
|
||||||
|
if cmp(&symbols[last_batch_start], next_symbol) == Ordering::Equal {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let start = last_batch_start;
|
let start = last_batch_start;
|
||||||
let end = idx + 1;
|
let end = idx + 1;
|
||||||
last_batch_start = end;
|
last_batch_start = end;
|
||||||
|
|
||||||
let key = symbols[start].name.as_str().to_lowercase();
|
let key = symbols[start].name.as_str().to_ascii_lowercase();
|
||||||
let value = SymbolIndex::range_to_map_value(start, end);
|
let value = SymbolIndex::range_to_map_value(start, end);
|
||||||
|
|
||||||
builder.insert(key, value).unwrap();
|
builder.insert(key, value).unwrap();
|
||||||
|
|
Loading…
Reference in a new issue