Skip to content

Commit

Permalink
deps: update regex crate
Browse files Browse the repository at this point in the history
This update brings with it a new feature of the regex crate which will
now use SIMD optimizations automatically at runtime with no necessary
compile time flags. All that's needed is to enable the `unstable` feature.

Other crates, such as bytecount and encoding_rs, are still using the
old-style SIMD support, so we leave the simd-accel and avx-accel features.
However, the binaries we distribute on Github no longer have those
features enabled, which makes them truly portable.

Fixes #135
  • Loading branch information
BurntSushi committed Mar 13, 2018
1 parent 00520b3 commit f87902e
Show file tree
Hide file tree
Showing 9 changed files with 42 additions and 24 deletions.
30 changes: 22 additions & 8 deletions Cargo.lock

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

7 changes: 4 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ log = "0.4"
memchr = "2"
memmap = "0.6"
num_cpus = "1"
regex = "0.2.4"
regex = "0.2.9"
same-file = "1"
termcolor = { version = "0.3.4", path = "termcolor" }

Expand All @@ -67,12 +67,13 @@ default-features = false
features = ["suggestions", "color"]

[features]
avx-accel = ["bytecount/avx-accel"]
avx-accel = ["bytecount/avx-accel", "regex/unstable"]
simd-accel = [
"bytecount/simd-accel",
"regex/simd-accel",
"encoding_rs/simd-accel",
"regex/unstable",
]
unstable = ["regex/unstable"]

[profile.release]
debug = true
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,14 @@ If you're a **Rust programmer**, ripgrep can be installed with `cargo`.
$ cargo install ripgrep
```

If you're using Rust nightly, then use

```
$ cargo install ripgrep --features unstable
```

to get SIMD optimizations.

ripgrep isn't currently in any other package repositories.
[I'd like to change that](https://github.com/BurntSushi/ripgrep/issues/10).

Expand All @@ -312,7 +320,8 @@ RUSTFLAGS="-C target-cpu=native" cargo build --release --features 'simd-accel av
```

If your machine doesn't support AVX instructions, then simply remove
`avx-accel` from the features list. Similarly for SIMD.
`avx-accel` from the features list. Similarly for SIMD (which corresponds
roughly to SSE instructions).


### Running tests
Expand Down
3 changes: 1 addition & 2 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ test_script:

before_deploy:
# Generate artifacts for release
# TODO(burntsushi): How can we enable SSSE3 on Windows?
- cargo build --release
- cargo build --release --features unstable
- mkdir staging
- copy target\release\rg.exe staging
- ps: copy target\release\build\ripgrep-*\out\_rg.ps1 staging
Expand Down
7 changes: 1 addition & 6 deletions ci/before_deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,7 @@ set -ex

# Generate artifacts for release
mk_artifacts() {
if is_ssse3_target; then
RUSTFLAGS="-C target-feature=+ssse3" \
cargo build --target "$TARGET" --release --features simd-accel
else
cargo build --target "$TARGET" --release
fi
cargo build --target "$TARGET" --release --features unstable
}

mk_tarball() {
Expand Down
2 changes: 1 addition & 1 deletion globset/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ aho-corasick = "0.6.0"
fnv = "1.0"
log = "0.4"
memchr = "2"
regex = "0.2.1"
regex = "0.2.9"

[dev-dependencies]
glob = "0.2"
Expand Down
2 changes: 1 addition & 1 deletion grep/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ license = "Unlicense/MIT"
[dependencies]
log = "0.4"
memchr = "2"
regex = "0.2.1"
regex = "0.2.9"
regex-syntax = "0.4.0"
2 changes: 1 addition & 1 deletion ignore/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ globset = { version = "0.3.0", path = "../globset" }
lazy_static = "1"
log = "0.4"
memchr = "2"
regex = "0.2.1"
regex = "0.2.9"
same-file = "1"
thread_local = "0.3.2"
walkdir = "2"
Expand Down
2 changes: 1 addition & 1 deletion src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -599,7 +599,7 @@ impl<'a> ArgMatches<'a> {
// This would normally just be an empty string, which works on its
// own, but if the patterns are joined in a set of alternations, then
// you wind up with `foo|`, which is invalid.
self.word_pattern("z{0}".to_string())
self.word_pattern("(?:z{0})*".to_string())
}

/// Returns true if and only if file names containing each match should
Expand Down

0 comments on commit f87902e

Please sign in to comment.