mirror of
https://github.com/crate-ci/typos.git
synced 2024-11-28 20:11:05 -05:00
perf(config): Get small-string optimization
This commit is contained in:
parent
b5827004a2
commit
75ba4ac535
3 changed files with 25 additions and 10 deletions
10
Cargo.lock
generated
10
Cargo.lock
generated
|
@ -724,6 +724,15 @@ dependencies = [
|
||||||
"wasm-bindgen",
|
"wasm-bindgen",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "kstring"
|
||||||
|
version = "1.0.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "1167388385b43067bd74f967def6c93b969284f14f41e2ab6035b715d9343215"
|
||||||
|
dependencies = [
|
||||||
|
"serde",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "lazy_static"
|
name = "lazy_static"
|
||||||
version = "1.4.0"
|
version = "1.4.0"
|
||||||
|
@ -1499,6 +1508,7 @@ dependencies = [
|
||||||
"human-panic",
|
"human-panic",
|
||||||
"ignore",
|
"ignore",
|
||||||
"itertools 0.10.0",
|
"itertools 0.10.0",
|
||||||
|
"kstring",
|
||||||
"log",
|
"log",
|
||||||
"phf",
|
"phf",
|
||||||
"predicates",
|
"predicates",
|
||||||
|
|
|
@ -57,6 +57,7 @@ derive_setters = "0.1"
|
||||||
itertools = "0.10"
|
itertools = "0.10"
|
||||||
serde_json = "1.0"
|
serde_json = "1.0"
|
||||||
encoding = "0.2"
|
encoding = "0.2"
|
||||||
|
kstring = "1.0"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
assert_fs = "1.0"
|
assert_fs = "1.0"
|
||||||
|
|
|
@ -260,12 +260,12 @@ pub struct FileConfig {
|
||||||
pub check_file: Option<bool>,
|
pub check_file: Option<bool>,
|
||||||
pub ignore_hex: Option<bool>,
|
pub ignore_hex: Option<bool>,
|
||||||
pub identifier_leading_digits: Option<bool>,
|
pub identifier_leading_digits: Option<bool>,
|
||||||
pub identifier_leading_chars: Option<String>,
|
pub identifier_leading_chars: Option<kstring::KString>,
|
||||||
pub identifier_include_digits: Option<bool>,
|
pub identifier_include_digits: Option<bool>,
|
||||||
pub identifier_include_chars: Option<String>,
|
pub identifier_include_chars: Option<kstring::KString>,
|
||||||
pub locale: Option<Locale>,
|
pub locale: Option<Locale>,
|
||||||
pub extend_identifiers: HashMap<String, String>,
|
pub extend_identifiers: HashMap<kstring::KString, kstring::KString>,
|
||||||
pub extend_words: HashMap<String, String>,
|
pub extend_words: HashMap<kstring::KString, kstring::KString>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl FileConfig {
|
impl FileConfig {
|
||||||
|
@ -277,9 +277,13 @@ impl FileConfig {
|
||||||
check_file: Some(empty.check_file()),
|
check_file: Some(empty.check_file()),
|
||||||
ignore_hex: Some(empty.ignore_hex()),
|
ignore_hex: Some(empty.ignore_hex()),
|
||||||
identifier_leading_digits: Some(empty.identifier_leading_digits()),
|
identifier_leading_digits: Some(empty.identifier_leading_digits()),
|
||||||
identifier_leading_chars: Some(empty.identifier_leading_chars().to_owned()),
|
identifier_leading_chars: Some(kstring::KString::from_ref(
|
||||||
|
empty.identifier_leading_chars(),
|
||||||
|
)),
|
||||||
identifier_include_digits: Some(empty.identifier_include_digits()),
|
identifier_include_digits: Some(empty.identifier_include_digits()),
|
||||||
identifier_include_chars: Some(empty.identifier_include_chars().to_owned()),
|
identifier_include_chars: Some(kstring::KString::from_ref(
|
||||||
|
empty.identifier_include_chars(),
|
||||||
|
)),
|
||||||
locale: Some(empty.locale()),
|
locale: Some(empty.locale()),
|
||||||
extend_identifiers: Default::default(),
|
extend_identifiers: Default::default(),
|
||||||
extend_words: Default::default(),
|
extend_words: Default::default(),
|
||||||
|
@ -303,13 +307,13 @@ impl FileConfig {
|
||||||
self.identifier_leading_digits = Some(source);
|
self.identifier_leading_digits = Some(source);
|
||||||
}
|
}
|
||||||
if let Some(source) = source.identifier_leading_chars() {
|
if let Some(source) = source.identifier_leading_chars() {
|
||||||
self.identifier_leading_chars = Some(source.to_owned());
|
self.identifier_leading_chars = Some(kstring::KString::from_ref(source));
|
||||||
}
|
}
|
||||||
if let Some(source) = source.identifier_include_digits() {
|
if let Some(source) = source.identifier_include_digits() {
|
||||||
self.identifier_include_digits = Some(source);
|
self.identifier_include_digits = Some(source);
|
||||||
}
|
}
|
||||||
if let Some(source) = source.identifier_include_chars() {
|
if let Some(source) = source.identifier_include_chars() {
|
||||||
self.identifier_include_chars = Some(source.to_owned());
|
self.identifier_include_chars = Some(kstring::KString::from_ref(source));
|
||||||
}
|
}
|
||||||
if let Some(source) = source.locale() {
|
if let Some(source) = source.locale() {
|
||||||
self.locale = Some(source);
|
self.locale = Some(source);
|
||||||
|
@ -317,12 +321,12 @@ impl FileConfig {
|
||||||
self.extend_identifiers.extend(
|
self.extend_identifiers.extend(
|
||||||
source
|
source
|
||||||
.extend_identifiers()
|
.extend_identifiers()
|
||||||
.map(|(k, v)| (k.to_owned(), v.to_owned())),
|
.map(|(k, v)| (kstring::KString::from_ref(k), kstring::KString::from_ref(v))),
|
||||||
);
|
);
|
||||||
self.extend_words.extend(
|
self.extend_words.extend(
|
||||||
source
|
source
|
||||||
.extend_words()
|
.extend_words()
|
||||||
.map(|(k, v)| (k.to_owned(), v.to_owned())),
|
.map(|(k, v)| (kstring::KString::from_ref(k), kstring::KString::from_ref(v))),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue