summaryrefslogtreecommitdiffstats
path: root/grep-pcre2
diff options
context:
space:
mode:
authorAndrew Gallant <jamslam@gmail.com>2018-09-08 17:12:14 -0400
committerAndrew Gallant <jamslam@gmail.com>2018-09-08 17:12:14 -0400
commiteb18da04506b959c0251099eae83e16d22ce8bcb (patch)
tree7ecd2c8e0afdf81eec1c883a322082f9643834c9 /grep-pcre2
parent0f7494216f55bb5d373027c2039d8c26dbc4a564 (diff)
pcre2: use jit_if_availablegrep-pcre2-0.1.2grep-0.2.3
This will allow PCRE2 to fall back to non-JIT matching when running on platforms without JIT support. ref https://github.com/BurntSushi/rust-pcre2/issues/3
Diffstat (limited to 'grep-pcre2')
-rw-r--r--grep-pcre2/Cargo.toml4
-rw-r--r--grep-pcre2/src/matcher.rs22
2 files changed, 22 insertions, 4 deletions
diff --git a/grep-pcre2/Cargo.toml b/grep-pcre2/Cargo.toml
index 1ec12302..0635a525 100644
--- a/grep-pcre2/Cargo.toml
+++ b/grep-pcre2/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "grep-pcre2"
-version = "0.1.1" #:version
+version = "0.1.2" #:version
authors = ["Andrew Gallant <jamslam@gmail.com>"]
description = """
Use PCRE2 with the 'grep' crate.
@@ -14,4 +14,4 @@ license = "Unlicense/MIT"
[dependencies]
grep-matcher = { version = "0.1.1", path = "../grep-matcher" }
-pcre2 = "0.1.0"
+pcre2 = "0.1.1"
diff --git a/grep-pcre2/src/matcher.rs b/grep-pcre2/src/matcher.rs
index e9c51be2..105448fe 100644
--- a/grep-pcre2/src/matcher.rs
+++ b/grep-pcre2/src/matcher.rs
@@ -199,16 +199,34 @@ impl RegexMatcherBuilder {
self
}
- /// Enable PCRE2's JIT.
+ /// Enable PCRE2's JIT and return an error if it's not available.
///
/// This generally speeds up matching quite a bit. The downside is that it
/// can increase the time it takes to compile a pattern.
///
- /// This is disabled by default.
+ /// If the JIT isn't available or if JIT compilation returns an error, then
+ /// regex compilation will fail with the corresponding error.
+ ///
+ /// This is disabled by default, and always overrides `jit_if_available`.
pub fn jit(&mut self, yes: bool) -> &mut RegexMatcherBuilder {
self.builder.jit(yes);
self
}
+
+ /// Enable PCRE2's JIT if it's available.
+ ///
+ /// This generally speeds up matching quite a bit. The downside is that it
+ /// can increase the time it takes to compile a pattern.
+ ///
+ /// If the JIT isn't available or if JIT compilation returns an error,
+ /// then a debug message with the error will be emitted and the regex will
+ /// otherwise silently fall back to non-JIT matching.
+ ///
+ /// This is disabled by default, and always overrides `jit`.
+ pub fn jit_if_available(&mut self, yes: bool) -> &mut RegexMatcherBuilder {
+ self.builder.jit_if_available(yes);
+ self
+ }
}
/// An implementation of the `Matcher` trait using PCRE2.