build: trim prototype dependencies
This commit is contained in:
parent
5bffeea1fb
commit
1904979405
|
|
@ -167,31 +167,6 @@ dependencies = [
|
|||
"cfg-if",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crossbeam-deque"
|
||||
version = "0.8.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "622f3fc73690be383c7214310406f28a90e6edeadc3cea882f9d71e495b9711a"
|
||||
dependencies = [
|
||||
"crossbeam-epoch",
|
||||
"crossbeam-utils",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crossbeam-epoch"
|
||||
version = "0.9.21"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dc74980687109a3b14c72fd458107bf0baa1da1a1a805e178d15501ba9b86d9d"
|
||||
dependencies = [
|
||||
"crossbeam-utils",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crossbeam-utils"
|
||||
version = "0.8.23"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a31eee39dddec8330830986fcd7625edb5a24ec90ea038215273bbc3adb08ac6"
|
||||
|
||||
[[package]]
|
||||
name = "crypto-common"
|
||||
version = "0.1.7"
|
||||
|
|
@ -247,12 +222,6 @@ dependencies = [
|
|||
"syn 3.0.6",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "either"
|
||||
version = "1.18.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "252afb9ae5eaa683babdc6a068b3f5726eb19e05070c731f9b2a23a7c3e8ed34"
|
||||
|
||||
[[package]]
|
||||
name = "equivalent"
|
||||
version = "1.0.2"
|
||||
|
|
@ -471,12 +440,9 @@ name = "john_slop"
|
|||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"miette",
|
||||
"once_cell",
|
||||
"rayon",
|
||||
"regex",
|
||||
"tempfile",
|
||||
"thiserror",
|
||||
"unicode-segmentation",
|
||||
"walkdir",
|
||||
"zip",
|
||||
]
|
||||
|
|
@ -662,26 +628,6 @@ version = "6.0.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf"
|
||||
|
||||
[[package]]
|
||||
name = "rayon"
|
||||
version = "1.12.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fb39b166781f92d482534ef4b4b1b2568f42613b53e5b6c160e24cfbfa30926d"
|
||||
dependencies = [
|
||||
"either",
|
||||
"rayon-core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rayon-core"
|
||||
version = "1.13.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "22e18b0f0062d30d4230b2e85ff77fdfe4326feb054b9783a3460d8435c8ab91"
|
||||
dependencies = [
|
||||
"crossbeam-deque",
|
||||
"crossbeam-utils",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "regex"
|
||||
version = "1.13.1"
|
||||
|
|
@ -970,12 +916,6 @@ version = "1.0.26"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d245f478577f809a851594d02313b640fb437e0bb33866753cff937863096954"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-segmentation"
|
||||
version = "1.13.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c6f5d3c3b1bf09027a88a6bc961fc00497d651009560b5463668dc81b0fa87a8"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-width"
|
||||
version = "0.1.14"
|
||||
|
|
|
|||
|
|
@ -8,11 +8,10 @@ repository = "https://git.dandaedre.com/idle-org/john_slop"
|
|||
|
||||
[dependencies]
|
||||
miette = { version = "7.6.0", features = ["fancy"] }
|
||||
once_cell = "1.21.3"
|
||||
rayon = "1.11.0"
|
||||
regex = "1.12.2"
|
||||
tempfile = "3.23.0"
|
||||
thiserror = "2.0.17"
|
||||
unicode-segmentation = "1.12.0"
|
||||
walkdir = "2.5.0"
|
||||
zip = "6.0.0"
|
||||
|
||||
[dev-dependencies]
|
||||
tempfile = "3.23.0"
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
//! All detection function & modules
|
||||
//!
|
||||
use once_cell::sync::Lazy;
|
||||
use regex::{Regex, RegexBuilder};
|
||||
use std::sync::LazyLock;
|
||||
|
||||
/// A tiny “search‑engine” that knows a *set* of Unicode code‑points.
|
||||
/// It returns the **byte** offset of every match (so the positions are
|
||||
/// deterministic even if you run the search in parallel).
|
||||
static HYPHEN_REGEX: Lazy<Regex> = Lazy::new(|| {
|
||||
static HYPHEN_REGEX: LazyLock<Regex> = LazyLock::new(|| {
|
||||
// All the Unicode characters that look like a hyphen.
|
||||
// (U+002D, U+2010, U+2011, U+2012, U+2013, U+2014, U+2015, …)
|
||||
let pattern = r"[\u002D\u2010\u2011\u2012\u2013\u2014\u2015\u2212\uFE58\uFE63\uFF0D]";
|
||||
|
|
@ -30,8 +30,6 @@ fn find_all(re: &Regex, text: &str) -> Vec<(usize, usize, char)> {
|
|||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use rayon::prelude::*;
|
||||
use unicode_segmentation::UnicodeSegmentation;
|
||||
|
||||
#[test]
|
||||
fn it_finds_all_hyphens() {
|
||||
|
|
@ -54,35 +52,13 @@ mod tests {
|
|||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn it_is_thread_safe_and_can_run_in_parallel() {
|
||||
// A big dummy string that contains a bunch of hyphen variants.
|
||||
let s = (0..10_000)
|
||||
.map(|i| if i % 3 == 0 { "—" } else { "-" })
|
||||
.collect::<String>();
|
||||
|
||||
// Pretend we have two different regexes to search (just one here).
|
||||
let regexes = vec![&*HYPHEN_REGEX];
|
||||
|
||||
// Parallel search (one thread per regex – not the fastest, but
|
||||
// shows the “share‑regex‑between‑threads” pattern).
|
||||
let results: Vec<Vec<_>> = regexes.par_iter().map(|re| find_all(re, &s)).collect();
|
||||
|
||||
// All regexes returned the same count.
|
||||
assert_eq!(results[0].len(), 10_000);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn regex_offsets_are_utf8_byte_offsets() {
|
||||
// U+1D306 is one grapheme cluster and occupies four bytes in UTF-8.
|
||||
let s = "a𝌆b";
|
||||
|
||||
let symbol_start = s.grapheme_indices(true).nth(1).unwrap().0;
|
||||
assert_eq!(symbol_start, 1);
|
||||
|
||||
let symbol_regex = Regex::new(r"\u{1D306}").unwrap();
|
||||
let matched = symbol_regex.find(s).unwrap();
|
||||
assert_eq!(matched.range(), 1..5);
|
||||
assert_eq!(matched.start(), symbol_start);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
2
tasks.md
2
tasks.md
|
|
@ -36,7 +36,7 @@ audit in CI.
|
|||
symlinks, and ignore rules.
|
||||
- [x] Establish an MSRV in `Cargo.toml` and CI, add license/repository metadata,
|
||||
and document supported platforms.
|
||||
- [ ] Move `tempfile` and other test-only crates to `[dev-dependencies]`; remove
|
||||
- [x] Move `tempfile` and other test-only crates to `[dev-dependencies]`; remove
|
||||
`rayon`, `once_cell`, or `unicode-segmentation` if the final design does not
|
||||
justify them.
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue