mirror of
https://github.com/crate-ci/typos.git
synced 2024-12-23 16:12:25 -05:00
2b1f565eaa
This dropped RSS (memory usage) from 4GB to 1.5GB when compiling. The extra `match` could impact performance but not too concerned since the default is to not look within vars.
28 lines
717 B
Rust
28 lines
717 B
Rust
mod vars_codegen;
|
|
|
|
pub use crate::vars_codegen::*;
|
|
|
|
pub use varcon_core::Category;
|
|
pub use varcon_core::CategorySet;
|
|
|
|
pub fn find(word: &'_ unicase::UniCase<&str>) -> Option<&'static [(u8, &'static VariantsMap)]> {
|
|
VARS_DICTIONARY
|
|
.binary_search_by_key(word, |(key, _)| key.convert())
|
|
.map(|i| VARS_DICTIONARY[i].1)
|
|
.ok()
|
|
}
|
|
|
|
#[derive(Copy, Clone, Debug)]
|
|
pub(crate) enum EncodedStr {
|
|
//Unicode(&'static str),
|
|
Ascii(&'static str),
|
|
}
|
|
|
|
impl EncodedStr {
|
|
fn convert(self) -> unicase::UniCase<&'static str> {
|
|
match self {
|
|
//EncodedStr::Unicode(s) => unicase::UniCase::unicode(s),
|
|
EncodedStr::Ascii(s) => unicase::UniCase::ascii(s),
|
|
}
|
|
}
|
|
}
|