Skip to content

Commit

Permalink
Replace regex by regex-lite.
Browse files Browse the repository at this point in the history
This can drastically improve the performance of regexes on smaller
strings. For example:

`limit(100000; repeat("--")) | match("^-="; "").string`

takes about
0.9 seconds with `regex`, but only
0.3 seconds with `regex-lite`.
  • Loading branch information
01mf02 committed Oct 28, 2024
1 parent d9b91b8 commit 0840b1b
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 32 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/msrv.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
working-directory: jaq-json
run: cargo check

- uses: dtolnay/rust-toolchain@1.64
- uses: dtolnay/rust-toolchain@1.65
- name: Check jaq
working-directory: jaq
run: cargo check
Expand Down
31 changes: 4 additions & 27 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions jaq-std/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ readme = "../README.md"
description = "Standard library for jaq"
repository = "https://github.com/01mf02/jaq"
keywords = ["json", "query", "jq"]
rust-version = "1.63"
rust-version = "1.65"

[features]
default = ["std", "format", "log", "math", "regex", "time"]
regex = ["regex-lite"]
std = []
format = ["aho-corasick", "base64", "urlencoding"]
math = ["libm"]
Expand All @@ -22,7 +23,7 @@ jaq-core = { version = "2.0.0-gamma", path = "../jaq-core" }

hifijson = { version = "0.2.0", optional = true }
chrono = { version = "0.4.38", default-features = false, features = ["alloc"], optional = true }
regex = { version = "1.9", optional = true }
regex-lite = { version = "0.1", optional = true }
log = { version = "0.4.17", optional = true }
libm = { version = "0.2.7", optional = true }
aho-corasick = { version = "1.0", optional = true }
Expand Down
2 changes: 1 addition & 1 deletion jaq-std/src/regex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
use alloc::string::{String, ToString};
use alloc::vec::Vec;
use regex::{Error, Regex, RegexBuilder};
use regex_lite::{self as regex, Error, Regex, RegexBuilder};

#[derive(Copy, Clone, Default)]
pub struct Flags {
Expand Down
2 changes: 1 addition & 1 deletion jaq/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ description = "Just another JSON query tool"
repository = "https://github.com/01mf02/jaq"
keywords = ["json", "query", "jq"]
categories = ["command-line-utilities", "compilers", "parser-implementations"]
rust-version = "1.64"
rust-version = "1.65"

[features]
default = ["mimalloc"]
Expand Down

0 comments on commit 0840b1b

Please sign in to comment.