Skip to content

Offline, privacy-first grammar checker. Fast, open-source, Rust-powered

fix: made minor perf tweaks related to #119

Elijah Potter916858c2f3e1
diff --git a/Cargo.lock b/Cargo.lock
index 34fcbf58d..3cf8910b9 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -50,6 +50,12 @@ version = "0.2.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f"
+[[package]]
+name = "anes"
+version = "0.1.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4b46cbb362ab8752921c97e041f5e366ee6297bd428a31275b9fcf1e380f7299"
+
[[package]]
name = "anstream"
version = "0.6.14"
@@ -126,17 +132,6 @@ dependencies = [
"syn",
]
-[[package]]
-name = "atty"
-version = "0.2.14"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8"
-dependencies = [
- "hermit-abi 0.1.19",
- "libc",
- "winapi",
-]
-
[[package]]
name = "auto_impl"
version = "1.2.0"
@@ -223,14 +218,30 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
-name = "clap"
-version = "2.34.0"
+name = "ciborium"
+version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c"
+checksum = "42e69ffd6f0917f5c029256a24d0161db17cea3997d185db0d35926308770f0e"
dependencies = [
- "bitflags 1.3.2",
- "textwrap",
- "unicode-width",
+ "ciborium-io",
+ "ciborium-ll",
+ "serde",
+]
+
+[[package]]
+name = "ciborium-io"
+version = "0.2.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "05afea1e0a06c9be33d539b876f1ce3692f4afea2cb41f740e7743225ed1c757"
+
+[[package]]
+name = "ciborium-ll"
+version = "0.2.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "57663b653d948a338bfb3eeba9bb2fd5fcfaecb9e199e87e1eda4d9e8b240fd9"
+dependencies = [
+ "ciborium-io",
+ "half",
]
[[package]]
@@ -291,24 +302,24 @@ dependencies = [
[[package]]
name = "criterion"
-version = "0.3.6"
+version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b01d6de93b2b6c65e17c634a26653a29d107b3c98c607c765bf38d041531cd8f"
+checksum = "f2b12d017a929603d80db1831cd3a24082f8137ce19c69e6447f54f5fc8d692f"
dependencies = [
- "atty",
+ "anes",
"cast",
- "clap 2.34.0",
+ "ciborium",
+ "clap",
"criterion-plot",
- "csv",
+ "is-terminal",
"itertools 0.10.5",
- "lazy_static",
"num-traits",
+ "once_cell",
"oorandom",
"plotters",
"rayon",
"regex",
"serde",
- "serde_cbor",
"serde_derive",
"serde_json",
"tinytemplate",
@@ -317,9 +328,9 @@ dependencies = [
[[package]]
name = "criterion-plot"
-version = "0.4.5"
+version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2673cc8207403546f45f5fd319a974b1e6983ad1a3ee7e6041650013be041876"
+checksum = "6b50826342786a51a89e2da3a28f1c32b06e387201bc2d19791f622c673706b1"
dependencies = [
"cast",
"itertools 0.10.5",
@@ -351,25 +362,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80"
[[package]]
-name = "csv"
-version = "1.3.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ac574ff4d437a7b5ad237ef331c17ccca63c46479e5b5453eb8e10bb99a759fe"
-dependencies = [
- "csv-core",
- "itoa",
- "ryu",
- "serde",
-]
-
-[[package]]
-name = "csv-core"
-version = "0.1.11"
+name = "crunchy"
+version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "5efa2b3d7902f4b634a20cae3c9c4e6209dc4779feb6863329607560143efa70"
-dependencies = [
- "memchr",
-]
+checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7"
[[package]]
name = "dashmap"
@@ -557,9 +553,13 @@ checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253"
[[package]]
name = "half"
-version = "1.8.3"
+version = "2.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1b43ede17f21864e81be2fa654110bf1e793774238d86ef8555c37e6519c0403"
+checksum = "6dd08c532ae367adf81c312a4580bc67f1d0fe8bc9c460520283f4c0ff277888"
+dependencies = [
+ "cfg-if",
+ "crunchy",
+]
[[package]]
name = "harper-cli"
@@ -567,7 +567,7 @@ version = "0.1.0"
dependencies = [
"anyhow",
"ariadne",
- "clap 4.5.4",
+ "clap",
"harper-comments",
"harper-core",
]
@@ -634,7 +634,7 @@ name = "harper-ls"
version = "0.9.5"
dependencies = [
"anyhow",
- "clap 4.5.4",
+ "clap",
"dirs 5.0.1",
"futures",
"harper-comments",
@@ -691,18 +691,15 @@ checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
[[package]]
name = "hermit-abi"
-version = "0.1.19"
+version = "0.3.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33"
-dependencies = [
- "libc",
-]
+checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024"
[[package]]
name = "hermit-abi"
-version = "0.3.9"
+version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024"
+checksum = "fbf6a919d6cf397374f7dfeeea91d974c7c0a7221d0d0f4f20d859d329e53fcc"
[[package]]
name = "httparse"
@@ -741,6 +738,17 @@ dependencies = [
"syn",
]
+[[package]]
+name = "is-terminal"
+version = "0.4.13"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "261f68e344040fbd0edea105bef17c66edf46f984ddb1115b775ce31be948f4b"
+dependencies = [
+ "hermit-abi 0.4.0",
+ "libc",
+ "windows-sys 0.52.0",
+]
+
[[package]]
name = "is-wsl"
version = "0.4.0"
@@ -1227,16 +1235,6 @@ dependencies = [
"serde_derive",
]
-[[package]]
-name = "serde_cbor"
-version = "0.11.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2bef2ebfde456fb76bbcf9f59315333decc4fda0b2b44b420243c11e0f5ec1f5"
-dependencies = [
- "half",
- "serde",
-]
-
[[package]]
name = "serde_derive"
version = "1.0.203"
@@ -1325,15 +1323,6 @@ dependencies = [
"unicode-ident",
]
-[[package]]
-name = "textwrap"
-version = "0.11.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060"
-dependencies = [
- "unicode-width",
-]
-
[[package]]
name = "thiserror"
version = "1.0.60"
diff --git a/harper-core/Cargo.toml b/harper-core/Cargo.toml
index 0801d259b..76d4d3406 100644
--- a/harper-core/Cargo.toml
+++ b/harper-core/Cargo.toml
@@ -22,7 +22,7 @@ unicode-blocks = "0.1.9"
unicode-width = "0.1.11"
[dev-dependencies]
-criterion = "0.3"
+criterion = "0.5.1"
rand = "0.8.5"
[[bench]]
diff --git a/harper-core/benches/parse_demo.rs b/harper-core/benches/parse_demo.rs
index 1250048cd..7d49cf91d 100644
--- a/harper-core/benches/parse_demo.rs
+++ b/harper-core/benches/parse_demo.rs
@@ -25,7 +25,7 @@ fn lint_demo_uncached(c: &mut Criterion) {
b.iter(|| {
let dictionary = FullDictionary::curated();
let mut lint_set = LintGroup::new(LintGroupConfig::default(), dictionary.clone());
- let document = Document::new_markdown_curated(black_box(DEMO));
+ let document = Document::new_markdown(black_box(DEMO), &dictionary);
lint_set.lint(&document)
})
});
diff --git a/harper-core/dictionary.dict b/harper-core/dictionary.dict
index b016dc6f7..3de2b6a4c 100644
--- a/harper-core/dictionary.dict
+++ b/harper-core/dictionary.dict
@@ -49643,12 +49643,14 @@ TOML/M2
Ambien/SM1
config/SM14
royale/SM15
-KanBan/M
-Pandoc/M
-Sioyek/M
+KanBan/M1
+Pandoc/M1
+Sioyek/M1
Firestore/M
substring/SM14
Rosenthal/SM2
ACM/M1
scatterplot/SMG14
Wikilink/MS1
+stacktrace/SM1
+scrollbar/SM1
diff --git a/harper-core/src/char_string.rs b/harper-core/src/char_string.rs
index 6945a58ff..3a30889c6 100644
--- a/harper-core/src/char_string.rs
+++ b/harper-core/src/char_string.rs
@@ -1,8 +1,8 @@
use smallvec::SmallVec;
/// A char sequence that improves cache locality.
-/// Most English words are fewer than 6 characters.
-pub type CharString = SmallVec<[char; 6]>;
+/// Most English words are fewer than 12 characters.
+pub type CharString = SmallVec<[char; 12]>;
pub trait CharStringExt {
fn to_lower(&self) -> CharString;