Skip to content

Commit 49f2a3d

Browse files
mrmondayBurntSushi
authored andcommitted
Add d-phobos bench feature to reduce duplication
1 parent fe9d82b commit 49f2a3d

File tree

4 files changed

+11
-18
lines changed

4 files changed

+11
-18
lines changed

bench/Cargo.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,9 @@ re-pcre1 = ["libpcre-sys"]
4747
re-pcre2 = []
4848
re-onig = ["onig"]
4949
re-re2 = []
50-
re-dphobos-dmd = []
51-
re-dphobos-ldc = []
50+
re-dphobos = []
51+
re-dphobos-dmd = ["re-dphobos"]
52+
re-dphobos-ldc = ["re-dphobos"]
5253
re-rust = []
5354
re-rust-bytes = []
5455
re-tcl = []

bench/src/bench.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@ pub use ffi::pcre1::Regex;
3737
pub use ffi::pcre2::Regex;
3838
#[cfg(feature = "re-re2")]
3939
pub use ffi::re2::Regex;
40-
#[cfg(any(feature = "re-dphobos-dmd",
41-
feature = "re-dphobos-ldc"))]
40+
#[cfg(feature = "re-dphobos")]
4241
pub use ffi::d_phobos::Regex;
4342
#[cfg(feature = "re-rust")]
4443
pub use regex::Regex;
@@ -92,8 +91,7 @@ macro_rules! text {
9291
feature = "re-pcre1",
9392
feature = "re-pcre2",
9493
feature = "re-re2",
95-
feature = "re-dphobos-ldc",
96-
feature = "re-dphobos-dmd",
94+
feature = "re-dphobos",
9795
feature = "re-rust",
9896
))]
9997
macro_rules! text {
@@ -110,8 +108,7 @@ type Text = Vec<u8>;
110108
feature = "re-pcre1",
111109
feature = "re-pcre2",
112110
feature = "re-re2",
113-
feature = "re-dphobos-ldc",
114-
feature = "re-dphobos-dmd",
111+
feature = "re-dphobos",
115112
feature = "re-rust",
116113
))]
117114
type Text = String;

bench/src/ffi/mod.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@
1212
// of conditional compilation and such.
1313
#![allow(dead_code)]
1414

15-
#[cfg(any(feature = "re-dphobos-dmd",
16-
feature = "re-dphobos-ldc"))]
15+
#[cfg(feature = "re-dphobos")]
1716
pub mod d_phobos;
1817
#[cfg(feature = "re-onig")]
1918
pub mod onig;

bench/src/sherlock.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -88,14 +88,12 @@ sherlock!(the_whitespace, r"the\s+\w+", 5410);
8888

8989
// How fast can we match everything? This essentially defeats any clever prefix
9090
// tricks and just executes the DFA across the entire input.
91-
#[cfg(not(feature = "re-dphobos-dmd"))]
92-
#[cfg(not(feature = "re-dphobos-ldc"))]
91+
#[cfg(not(feature = "re-dphobos"))]
9392
#[cfg(not(feature = "re-pcre1"))]
9493
#[cfg(not(feature = "re-pcre2"))]
9594
#[cfg(not(feature = "re-tcl"))]
9695
sherlock!(everything_greedy, r".*", 13053);
97-
#[cfg(not(feature = "re-dphobos-dmd"))]
98-
#[cfg(not(feature = "re-dphobos-ldc"))]
96+
#[cfg(not(feature = "re-dphobos"))]
9997
#[cfg(not(feature = "re-onig"))]
10098
#[cfg(not(feature = "re-pcre1"))]
10199
#[cfg(not(feature = "re-pcre2"))]
@@ -152,15 +150,13 @@ sherlock!(quotes, r#"["'][^"']{0,30}[?!.]["']"#, 767);
152150
// Finds all occurrences of Sherlock Holmes at the beginning or end of a line.
153151
// The empty assertions defeat any detection of prefix literals, so it's the
154152
// lazy DFA the entire way.
155-
#[cfg(not(any(feature = "re-dphobos-dmd",
156-
feature = "re-dphobos-ldc")))]
153+
#[cfg(not(feature = "re-dphobos"))]
157154
sherlock!(
158155
line_boundary_sherlock_holmes,
159156
r"(?m)^Sherlock Holmes|Sherlock Holmes$",
160157
34);
161158
// D matches both \r\n and \n as EOL
162-
#[cfg(any(feature = "re-dphobos-dmd",
163-
feature = "re-dphobos-ldc"))]
159+
#[cfg(feature = "re-dphobos")]
164160
sherlock!(
165161
line_boundary_sherlock_holmes,
166162
r"(?m)^Sherlock Holmes|Sherlock Holmes$",

0 commit comments

Comments
 (0)