mirror of
https://github.com/crate-ci/typos.git
synced 2024-11-25 10:31:02 -05:00
chore: Reduce code-gen memory usage
More `const fn` removals to reduce compilation memory use
This commit is contained in:
parent
a861cbfb1f
commit
3a4d039c4f
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 = [
|
dependencies = [
|
||||||
"codegenrs",
|
"codegenrs",
|
||||||
"itertools 0.10.0",
|
"itertools 0.10.0",
|
||||||
"phf",
|
|
||||||
"phf_codegen",
|
|
||||||
"structopt",
|
"structopt",
|
||||||
"unicase",
|
"unicase",
|
||||||
]
|
]
|
||||||
|
@ -233,7 +231,6 @@ name = "codespell-dict"
|
||||||
version = "0.4.0"
|
version = "0.4.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"log",
|
"log",
|
||||||
"phf",
|
|
||||||
"unicase",
|
"unicase",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -808,8 +805,6 @@ version = "0.4.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"codegenrs",
|
"codegenrs",
|
||||||
"itertools 0.10.0",
|
"itertools 0.10.0",
|
||||||
"phf",
|
|
||||||
"phf_codegen",
|
|
||||||
"regex",
|
"regex",
|
||||||
"structopt",
|
"structopt",
|
||||||
"unicase",
|
"unicase",
|
||||||
|
@ -820,7 +815,6 @@ name = "misspell-dict"
|
||||||
version = "0.4.0"
|
version = "0.4.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"log",
|
"log",
|
||||||
"phf",
|
|
||||||
"unicase",
|
"unicase",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -1778,8 +1772,6 @@ version = "0.4.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"codegenrs",
|
"codegenrs",
|
||||||
"itertools 0.10.0",
|
"itertools 0.10.0",
|
||||||
"phf",
|
|
||||||
"phf_codegen",
|
|
||||||
"structopt",
|
"structopt",
|
||||||
"unicase",
|
"unicase",
|
||||||
]
|
]
|
||||||
|
@ -1789,7 +1781,6 @@ name = "wikipedia-dict"
|
||||||
version = "0.4.0"
|
version = "0.4.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"log",
|
"log",
|
||||||
"phf",
|
|
||||||
"unicase",
|
"unicase",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,9 @@ publish = false
|
||||||
azure-devops = { project = "crate-ci", pipeline = "typos" }
|
azure-devops = { project = "crate-ci", pipeline = "typos" }
|
||||||
codecov = { repository = "crate-ci/typos" }
|
codecov = { repository = "crate-ci/typos" }
|
||||||
|
|
||||||
|
[package.metadata.release]
|
||||||
|
disable-release = true
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
phf = { version = "0.8", features = ["unicase"] }
|
|
||||||
unicase = "2.5"
|
unicase = "2.5"
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
|
|
|
@ -14,9 +14,10 @@ publish = false
|
||||||
azure-devops = { project = "crate-ci", pipeline = "typos" }
|
azure-devops = { project = "crate-ci", pipeline = "typos" }
|
||||||
codecov = { repository = "crate-ci/typos" }
|
codecov = { repository = "crate-ci/typos" }
|
||||||
|
|
||||||
|
[package.metadata.release]
|
||||||
|
disable-release = true
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
phf = { version = "0.8", features = ["unicase"] }
|
|
||||||
phf_codegen = "0.8"
|
|
||||||
unicase = "2.5"
|
unicase = "2.5"
|
||||||
itertools = "0.10"
|
itertools = "0.10"
|
||||||
codegenrs = "1.0"
|
codegenrs = "1.0"
|
||||||
|
|
|
@ -32,24 +32,18 @@ fn generate<W: std::io::Write>(file: &mut W) {
|
||||||
.unwrap();
|
.unwrap();
|
||||||
writeln!(file, "#![allow(clippy::unreadable_literal)]",).unwrap();
|
writeln!(file, "#![allow(clippy::unreadable_literal)]",).unwrap();
|
||||||
writeln!(file).unwrap();
|
writeln!(file).unwrap();
|
||||||
writeln!(file, "use unicase::UniCase;").unwrap();
|
|
||||||
|
|
||||||
let dict = parse_dict(DICT);
|
let dict = parse_dict(DICT);
|
||||||
|
|
||||||
writeln!(
|
writeln!(file, "pub static WORD_DICTIONARY: &[(&str, &[&str])] = &[").unwrap();
|
||||||
file,
|
|
||||||
"pub static WORD_DICTIONARY: phf::Map<unicase::UniCase<&'static str>, &[&'static str]> = ",
|
|
||||||
)
|
|
||||||
.unwrap();
|
|
||||||
let mut builder = phf_codegen::Map::new();
|
|
||||||
for (typo, corrections) in dict {
|
for (typo, corrections) in dict {
|
||||||
let value = itertools::join(corrections.iter().map(|s| format!("{:?}", s)), ", ");
|
let value = itertools::join(corrections.iter().map(|s| format!("{:?}", s)), ", ");
|
||||||
let value = format!("&[{}]", value);
|
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, "];").unwrap();
|
||||||
writeln!(file, "{}", codegenned).unwrap();
|
|
||||||
writeln!(file, ";").unwrap();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, StructOpt)]
|
#[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" }
|
azure-devops = { project = "crate-ci", pipeline = "typos" }
|
||||||
codecov = { repository = "crate-ci/typos" }
|
codecov = { repository = "crate-ci/typos" }
|
||||||
|
|
||||||
|
[package.metadata.release]
|
||||||
|
disable-release = true
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
phf = { version = "0.8", features = ["unicase"] }
|
|
||||||
unicase = "2.5"
|
unicase = "2.5"
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
|
|
|
@ -14,9 +14,10 @@ publish = false
|
||||||
azure-devops = { project = "crate-ci", pipeline = "typos" }
|
azure-devops = { project = "crate-ci", pipeline = "typos" }
|
||||||
codecov = { repository = "crate-ci/typos" }
|
codecov = { repository = "crate-ci/typos" }
|
||||||
|
|
||||||
|
[package.metadata.release]
|
||||||
|
disable-release = true
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
phf = { version = "0.8", features = ["unicase"] }
|
|
||||||
phf_codegen = "0.8"
|
|
||||||
unicase = "2.5"
|
unicase = "2.5"
|
||||||
itertools = "0.10"
|
itertools = "0.10"
|
||||||
codegenrs = "1.0"
|
codegenrs = "1.0"
|
||||||
|
|
|
@ -64,60 +64,70 @@ fn generate<W: std::io::Write>(file: &mut W) {
|
||||||
.unwrap();
|
.unwrap();
|
||||||
writeln!(file, "#![allow(clippy::unreadable_literal)]",).unwrap();
|
writeln!(file, "#![allow(clippy::unreadable_literal)]",).unwrap();
|
||||||
writeln!(file).unwrap();
|
writeln!(file).unwrap();
|
||||||
writeln!(file, "use unicase::UniCase;").unwrap();
|
|
||||||
|
|
||||||
let Words {
|
let Words {
|
||||||
main,
|
main,
|
||||||
american,
|
american,
|
||||||
british,
|
british,
|
||||||
} = parse_dict(DICT);
|
} = 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!(
|
writeln!(file, "pub static MAIN_DICTIONARY: &[(&str, &[&str])] = &[").unwrap();
|
||||||
file,
|
for (typo, corrections) in main.into_iter() {
|
||||||
"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 {
|
|
||||||
let value = itertools::join(corrections.iter().map(|s| format!("{:?}", s)), ", ");
|
let value = itertools::join(corrections.iter().map(|s| format!("{:?}", s)), ", ");
|
||||||
let value = format!("&[{}]", value);
|
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, "];").unwrap();
|
||||||
writeln!(file, "{}", codegenned).unwrap();
|
|
||||||
writeln!(file, ";").unwrap();
|
|
||||||
writeln!(file).unwrap();
|
writeln!(file).unwrap();
|
||||||
|
|
||||||
writeln!(
|
writeln!(
|
||||||
file,
|
file,
|
||||||
"pub static AMERICAN_DICTIONARY: phf::Map<unicase::UniCase<&'static str>, &[&'static str]> = ",
|
"pub static AMERICAN_DICTIONARY: &[(&str, &[&str])] = &["
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let mut builder = phf_codegen::Map::new();
|
for (typo, corrections) in american.into_iter() {
|
||||||
for (typo, corrections) in american {
|
|
||||||
let value = itertools::join(corrections.iter().map(|s| format!("{:?}", s)), ", ");
|
let value = itertools::join(corrections.iter().map(|s| format!("{:?}", s)), ", ");
|
||||||
let value = format!("&[{}]", value);
|
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, "];").unwrap();
|
||||||
writeln!(file, "{}", codegenned).unwrap();
|
|
||||||
writeln!(file, ";").unwrap();
|
|
||||||
writeln!(file).unwrap();
|
writeln!(file).unwrap();
|
||||||
|
|
||||||
writeln!(
|
writeln!(
|
||||||
file,
|
file,
|
||||||
"pub static BRITISH_DICTIONARY: phf::Map<unicase::UniCase<&'static str>, &[&'static str]> = ",
|
"pub static BRITISH_DICTIONARY: &[(&str, &[&str])] = &["
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let mut builder = phf_codegen::Map::new();
|
for (typo, corrections) in british.into_iter() {
|
||||||
for (typo, corrections) in british {
|
|
||||||
let value = itertools::join(corrections.iter().map(|s| format!("{:?}", s)), ", ");
|
let value = itertools::join(corrections.iter().map(|s| format!("{:?}", s)), ", ");
|
||||||
let value = format!("&[{}]", value);
|
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, "];").unwrap();
|
||||||
writeln!(file, "{}", codegenned).unwrap();
|
|
||||||
writeln!(file, ";").unwrap();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, StructOpt)]
|
#[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" }
|
azure-devops = { project = "crate-ci", pipeline = "typos" }
|
||||||
codecov = { repository = "crate-ci/typos" }
|
codecov = { repository = "crate-ci/typos" }
|
||||||
|
|
||||||
|
[package.metadata.release]
|
||||||
|
disable-release = true
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
phf = { version = "0.8", features = ["unicase"] }
|
|
||||||
unicase = "2.5"
|
unicase = "2.5"
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
|
|
|
@ -14,9 +14,10 @@ publish = false
|
||||||
azure-devops = { project = "crate-ci", pipeline = "typos" }
|
azure-devops = { project = "crate-ci", pipeline = "typos" }
|
||||||
codecov = { repository = "crate-ci/typos" }
|
codecov = { repository = "crate-ci/typos" }
|
||||||
|
|
||||||
|
[package.metadata.release]
|
||||||
|
disable-release = true
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
phf = { version = "0.8", features = ["unicase"] }
|
|
||||||
phf_codegen = "0.8"
|
|
||||||
unicase = "2.5"
|
unicase = "2.5"
|
||||||
itertools = "0.10"
|
itertools = "0.10"
|
||||||
codegenrs = "1.0"
|
codegenrs = "1.0"
|
||||||
|
|
|
@ -32,24 +32,18 @@ fn generate<W: std::io::Write>(file: &mut W) {
|
||||||
.unwrap();
|
.unwrap();
|
||||||
writeln!(file, "#![allow(clippy::unreadable_literal)]",).unwrap();
|
writeln!(file, "#![allow(clippy::unreadable_literal)]",).unwrap();
|
||||||
writeln!(file).unwrap();
|
writeln!(file).unwrap();
|
||||||
writeln!(file, "use unicase::UniCase;").unwrap();
|
|
||||||
|
|
||||||
let dict = parse_dict(DICT);
|
let dict = parse_dict(DICT);
|
||||||
|
|
||||||
writeln!(
|
writeln!(file, "pub static WORD_DICTIONARY: &[(&str, &[&str])] = &[").unwrap();
|
||||||
file,
|
|
||||||
"pub static WORD_DICTIONARY: phf::Map<unicase::UniCase<&'static str>, &[&'static str]> = ",
|
|
||||||
)
|
|
||||||
.unwrap();
|
|
||||||
let mut builder = phf_codegen::Map::new();
|
|
||||||
for (typo, corrections) in dict {
|
for (typo, corrections) in dict {
|
||||||
let value = itertools::join(corrections.iter().map(|s| format!("{:?}", s)), ", ");
|
let value = itertools::join(corrections.iter().map(|s| format!("{:?}", s)), ", ");
|
||||||
let value = format!("&[{}]", value);
|
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, "];").unwrap();
|
||||||
writeln!(file, "{}", codegenned).unwrap();
|
|
||||||
writeln!(file, ";").unwrap();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, StructOpt)]
|
#[derive(Debug, StructOpt)]
|
||||||
|
|
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue