mirror of
https://github.com/crate-ci/typos.git
synced 2024-11-25 10:31:02 -05:00
Merge pull request #280 from epage/bsearch
chore: Reduce code-gen memory usage
This commit is contained in:
commit
1612e077ac
13 changed files with 66706 additions and 81208 deletions
9
Cargo.lock
generated
9
Cargo.lock
generated
|
@ -222,8 +222,6 @@ version = "0.4.0"
|
|||
dependencies = [
|
||||
"codegenrs",
|
||||
"itertools 0.10.0",
|
||||
"phf",
|
||||
"phf_codegen",
|
||||
"structopt",
|
||||
"unicase",
|
||||
]
|
||||
|
@ -233,7 +231,6 @@ name = "codespell-dict"
|
|||
version = "0.4.0"
|
||||
dependencies = [
|
||||
"log",
|
||||
"phf",
|
||||
"unicase",
|
||||
]
|
||||
|
||||
|
@ -808,8 +805,6 @@ version = "0.4.0"
|
|||
dependencies = [
|
||||
"codegenrs",
|
||||
"itertools 0.10.0",
|
||||
"phf",
|
||||
"phf_codegen",
|
||||
"regex",
|
||||
"structopt",
|
||||
"unicase",
|
||||
|
@ -820,7 +815,6 @@ name = "misspell-dict"
|
|||
version = "0.4.0"
|
||||
dependencies = [
|
||||
"log",
|
||||
"phf",
|
||||
"unicase",
|
||||
]
|
||||
|
||||
|
@ -1778,8 +1772,6 @@ version = "0.4.0"
|
|||
dependencies = [
|
||||
"codegenrs",
|
||||
"itertools 0.10.0",
|
||||
"phf",
|
||||
"phf_codegen",
|
||||
"structopt",
|
||||
"unicase",
|
||||
]
|
||||
|
@ -1789,7 +1781,6 @@ name = "wikipedia-dict"
|
|||
version = "0.4.0"
|
||||
dependencies = [
|
||||
"log",
|
||||
"phf",
|
||||
"unicase",
|
||||
]
|
||||
|
||||
|
|
|
@ -15,7 +15,9 @@ publish = false
|
|||
azure-devops = { project = "crate-ci", pipeline = "typos" }
|
||||
codecov = { repository = "crate-ci/typos" }
|
||||
|
||||
[package.metadata.release]
|
||||
disable-release = true
|
||||
|
||||
[dependencies]
|
||||
phf = { version = "0.8", features = ["unicase"] }
|
||||
unicase = "2.5"
|
||||
log = "0.4"
|
||||
|
|
|
@ -14,9 +14,10 @@ publish = false
|
|||
azure-devops = { project = "crate-ci", pipeline = "typos" }
|
||||
codecov = { repository = "crate-ci/typos" }
|
||||
|
||||
[package.metadata.release]
|
||||
disable-release = true
|
||||
|
||||
[dependencies]
|
||||
phf = { version = "0.8", features = ["unicase"] }
|
||||
phf_codegen = "0.8"
|
||||
unicase = "2.5"
|
||||
itertools = "0.10"
|
||||
codegenrs = "1.0"
|
||||
|
|
|
@ -32,24 +32,18 @@ fn generate<W: std::io::Write>(file: &mut W) {
|
|||
.unwrap();
|
||||
writeln!(file, "#![allow(clippy::unreadable_literal)]",).unwrap();
|
||||
writeln!(file).unwrap();
|
||||
writeln!(file, "use unicase::UniCase;").unwrap();
|
||||
|
||||
let dict = parse_dict(DICT);
|
||||
|
||||
writeln!(
|
||||
file,
|
||||
"pub static WORD_DICTIONARY: phf::Map<unicase::UniCase<&'static str>, &[&'static str]> = ",
|
||||
)
|
||||
.unwrap();
|
||||
let mut builder = phf_codegen::Map::new();
|
||||
writeln!(file, "pub static WORD_DICTIONARY: &[(&str, &[&str])] = &[").unwrap();
|
||||
for (typo, corrections) in dict {
|
||||
let value = itertools::join(corrections.iter().map(|s| format!("{:?}", s)), ", ");
|
||||
let value = format!("&[{}]", value);
|
||||
builder.entry(unicase::UniCase::new(typo), &value);
|
||||
|
||||
let key = format!("{:?}", typo);
|
||||
writeln!(file, " ({}, {}),", key, &value).unwrap();
|
||||
}
|
||||
let codegenned = builder.build();
|
||||
writeln!(file, "{}", codegenned).unwrap();
|
||||
writeln!(file, ";").unwrap();
|
||||
writeln!(file, "];").unwrap();
|
||||
}
|
||||
|
||||
#[derive(Debug, StructOpt)]
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -15,7 +15,9 @@ publish = false
|
|||
azure-devops = { project = "crate-ci", pipeline = "typos" }
|
||||
codecov = { repository = "crate-ci/typos" }
|
||||
|
||||
[package.metadata.release]
|
||||
disable-release = true
|
||||
|
||||
[dependencies]
|
||||
phf = { version = "0.8", features = ["unicase"] }
|
||||
unicase = "2.5"
|
||||
log = "0.4"
|
||||
|
|
|
@ -14,9 +14,10 @@ publish = false
|
|||
azure-devops = { project = "crate-ci", pipeline = "typos" }
|
||||
codecov = { repository = "crate-ci/typos" }
|
||||
|
||||
[package.metadata.release]
|
||||
disable-release = true
|
||||
|
||||
[dependencies]
|
||||
phf = { version = "0.8", features = ["unicase"] }
|
||||
phf_codegen = "0.8"
|
||||
unicase = "2.5"
|
||||
itertools = "0.10"
|
||||
codegenrs = "1.0"
|
||||
|
|
|
@ -64,60 +64,70 @@ fn generate<W: std::io::Write>(file: &mut W) {
|
|||
.unwrap();
|
||||
writeln!(file, "#![allow(clippy::unreadable_literal)]",).unwrap();
|
||||
writeln!(file).unwrap();
|
||||
writeln!(file, "use unicase::UniCase;").unwrap();
|
||||
|
||||
let Words {
|
||||
main,
|
||||
american,
|
||||
british,
|
||||
} = parse_dict(DICT);
|
||||
let mut main: Vec<_> = main.into_iter().collect();
|
||||
main.sort_unstable_by(|a, b| {
|
||||
unicase::UniCase::new(a.0)
|
||||
.partial_cmp(&unicase::UniCase::new(b.0))
|
||||
.unwrap()
|
||||
});
|
||||
let mut american: Vec<_> = american.into_iter().collect();
|
||||
american.sort_unstable_by(|a, b| {
|
||||
unicase::UniCase::new(a.0)
|
||||
.partial_cmp(&unicase::UniCase::new(b.0))
|
||||
.unwrap()
|
||||
});
|
||||
let mut british: Vec<_> = british.into_iter().collect();
|
||||
british.sort_unstable_by(|a, b| {
|
||||
unicase::UniCase::new(a.0)
|
||||
.partial_cmp(&unicase::UniCase::new(b.0))
|
||||
.unwrap()
|
||||
});
|
||||
|
||||
writeln!(
|
||||
file,
|
||||
"pub static MAIN_DICTIONARY: phf::Map<unicase::UniCase<&'static str>, &[&'static str]> = ",
|
||||
)
|
||||
.unwrap();
|
||||
let mut builder = phf_codegen::Map::new();
|
||||
for (typo, corrections) in main {
|
||||
writeln!(file, "pub static MAIN_DICTIONARY: &[(&str, &[&str])] = &[").unwrap();
|
||||
for (typo, corrections) in main.into_iter() {
|
||||
let value = itertools::join(corrections.iter().map(|s| format!("{:?}", s)), ", ");
|
||||
let value = format!("&[{}]", value);
|
||||
builder.entry(unicase::UniCase::new(typo), &value);
|
||||
|
||||
let key = format!("{:?}", typo);
|
||||
writeln!(file, " ({}, {}),", key, &value).unwrap();
|
||||
}
|
||||
let codegenned = builder.build();
|
||||
writeln!(file, "{}", codegenned).unwrap();
|
||||
writeln!(file, ";").unwrap();
|
||||
writeln!(file, "];").unwrap();
|
||||
writeln!(file).unwrap();
|
||||
|
||||
writeln!(
|
||||
file,
|
||||
"pub static AMERICAN_DICTIONARY: phf::Map<unicase::UniCase<&'static str>, &[&'static str]> = ",
|
||||
"pub static AMERICAN_DICTIONARY: &[(&str, &[&str])] = &["
|
||||
)
|
||||
.unwrap();
|
||||
let mut builder = phf_codegen::Map::new();
|
||||
for (typo, corrections) in american {
|
||||
for (typo, corrections) in american.into_iter() {
|
||||
let value = itertools::join(corrections.iter().map(|s| format!("{:?}", s)), ", ");
|
||||
let value = format!("&[{}]", value);
|
||||
builder.entry(unicase::UniCase::new(typo), &value);
|
||||
|
||||
let key = format!("{:?}", typo);
|
||||
writeln!(file, " ({}, {}),", key, &value).unwrap();
|
||||
}
|
||||
let codegenned = builder.build();
|
||||
writeln!(file, "{}", codegenned).unwrap();
|
||||
writeln!(file, ";").unwrap();
|
||||
writeln!(file, "];").unwrap();
|
||||
writeln!(file).unwrap();
|
||||
|
||||
writeln!(
|
||||
file,
|
||||
"pub static BRITISH_DICTIONARY: phf::Map<unicase::UniCase<&'static str>, &[&'static str]> = ",
|
||||
"pub static BRITISH_DICTIONARY: &[(&str, &[&str])] = &["
|
||||
)
|
||||
.unwrap();
|
||||
let mut builder = phf_codegen::Map::new();
|
||||
for (typo, corrections) in british {
|
||||
for (typo, corrections) in british.into_iter() {
|
||||
let value = itertools::join(corrections.iter().map(|s| format!("{:?}", s)), ", ");
|
||||
let value = format!("&[{}]", value);
|
||||
builder.entry(unicase::UniCase::new(typo), &value);
|
||||
|
||||
let key = format!("{:?}", typo);
|
||||
writeln!(file, " ({}, {}),", key, &value).unwrap();
|
||||
}
|
||||
let codegenned = builder.build();
|
||||
writeln!(file, "{}", codegenned).unwrap();
|
||||
writeln!(file, ";").unwrap();
|
||||
writeln!(file, "];").unwrap();
|
||||
}
|
||||
|
||||
#[derive(Debug, StructOpt)]
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -15,7 +15,9 @@ publish = false
|
|||
azure-devops = { project = "crate-ci", pipeline = "typos" }
|
||||
codecov = { repository = "crate-ci/typos" }
|
||||
|
||||
[package.metadata.release]
|
||||
disable-release = true
|
||||
|
||||
[dependencies]
|
||||
phf = { version = "0.8", features = ["unicase"] }
|
||||
unicase = "2.5"
|
||||
log = "0.4"
|
||||
|
|
|
@ -14,9 +14,10 @@ publish = false
|
|||
azure-devops = { project = "crate-ci", pipeline = "typos" }
|
||||
codecov = { repository = "crate-ci/typos" }
|
||||
|
||||
[package.metadata.release]
|
||||
disable-release = true
|
||||
|
||||
[dependencies]
|
||||
phf = { version = "0.8", features = ["unicase"] }
|
||||
phf_codegen = "0.8"
|
||||
unicase = "2.5"
|
||||
itertools = "0.10"
|
||||
codegenrs = "1.0"
|
||||
|
|
|
@ -32,24 +32,18 @@ fn generate<W: std::io::Write>(file: &mut W) {
|
|||
.unwrap();
|
||||
writeln!(file, "#![allow(clippy::unreadable_literal)]",).unwrap();
|
||||
writeln!(file).unwrap();
|
||||
writeln!(file, "use unicase::UniCase;").unwrap();
|
||||
|
||||
let dict = parse_dict(DICT);
|
||||
|
||||
writeln!(
|
||||
file,
|
||||
"pub static WORD_DICTIONARY: phf::Map<unicase::UniCase<&'static str>, &[&'static str]> = ",
|
||||
)
|
||||
.unwrap();
|
||||
let mut builder = phf_codegen::Map::new();
|
||||
writeln!(file, "pub static WORD_DICTIONARY: &[(&str, &[&str])] = &[").unwrap();
|
||||
for (typo, corrections) in dict {
|
||||
let value = itertools::join(corrections.iter().map(|s| format!("{:?}", s)), ", ");
|
||||
let value = format!("&[{}]", value);
|
||||
builder.entry(unicase::UniCase::new(typo), &value);
|
||||
|
||||
let key = format!("{:?}", typo);
|
||||
writeln!(file, " ({}, {}),", key, &value).unwrap();
|
||||
}
|
||||
let codegenned = builder.build();
|
||||
writeln!(file, "{}", codegenned).unwrap();
|
||||
writeln!(file, ";").unwrap();
|
||||
writeln!(file, "];").unwrap();
|
||||
}
|
||||
|
||||
#[derive(Debug, StructOpt)]
|
||||
|
|
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue