commit_hash stringlengths 40 40 | author stringlengths 1 57 | date timestamp[s]date 2010-07-26 04:45:09 2026-04-14 18:21:10 | message stringlengths 8 1.39M | diff stringlengths 68 51.2k | files_changed int64 1 136 | insertions int64 0 2.35k | deletions int64 0 1.9k |
|---|---|---|---|---|---|---|---|
ca9ea654198e50f6f7574bbc644aa100534e2a2b | Andrew Gallant | 2023-10-01T16:53:51 | cargo: update description
This crate is not just "more than a safe interface to libc's memchr," it
is literally no longer that at all.
Fixes #138 | diff --git a/Cargo.toml b/Cargo.toml
index c37b72e..f681f44 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -2,12 +2,15 @@
name = "memchr"
version = "2.6.3" #:version
authors = ["Andrew Gallant <jamslam@gmail.com>", "bluss"]
-description = "Safe interface to memchr."
+description = """
+Provides extremely fast (uses SI... | 1 | 5 | 2 |
d5baf502a636372d956ff0a848c601ecd47c54c7 | Andrew Gallant | 2023-09-02T18:16:09 | arch/all/count: remove SWAR implementation of byte counting
It turns out that it was wrong. (See regression test that failed.)
Namely, the bit tricks used for the scalar version of memchr only tell
us whether a byte occurs within a usize, but not how many there are. It
seems like it should be able to be adapted to do ... | diff --git a/src/arch/all/memchr.rs b/src/arch/all/memchr.rs
index b211ad9..435b1be 100644
--- a/src/arch/all/memchr.rs
+++ b/src/arch/all/memchr.rs
@@ -257,32 +257,14 @@ impl One {
if start >= end {
return 0;
}
- let confirm = |b| self.confirm(b);
- let len = end.distance(s... | 1 | 19 | 38 |
a12d405fa7225d42bb125e9f2178516aaf4104ed | Conrad Ludgate | 2023-08-30T09:40:11 | api: make the memchr iterators implement Send/Sync
They did this previously, but due to some internally re-shuffling, these
impls got dropped accidentally. (Because the iterator switched to using
raw pointers.) They are still Send/Sync, we just need to explicitly opt
into it now. We also add a regression test to ensur... | diff --git a/src/arch/generic/memchr.rs b/src/arch/generic/memchr.rs
index 548e851..580b3cc 100644
--- a/src/arch/generic/memchr.rs
+++ b/src/arch/generic/memchr.rs
@@ -1011,6 +1011,16 @@ pub(crate) struct Iter<'h> {
haystack: core::marker::PhantomData<&'h [u8]>,
}
+// SAFETY: Iter contains no shared references... | 2 | 26 | 0 |
3a570a975f45af91dfe6bc10d91ba4f51394f840 | Andrew Gallant | 2023-08-29T15:37:21 | benchmarks: update memchr version, redux
I flubbed it in the previous commit. | diff --git a/benchmarks/engines/rust-memchr/Cargo.lock b/benchmarks/engines/rust-memchr/Cargo.lock
index 4058cc6..68c06f1 100644
--- a/benchmarks/engines/rust-memchr/Cargo.lock
+++ b/benchmarks/engines/rust-memchr/Cargo.lock
@@ -14,28 +14,24 @@ version = "1.6.0"
source = "registry+https://github.com/rust-lang/crates.i... | 2 | 6 | 10 |
77320559641b0fb7711e3b9761bc19b9b2f210f1 | Andrew Gallant | 2023-08-29T15:11:25 | benchmarks: update memchr version
Previously, we pinned memchr *and* pointed it to the current source
code. That means `rebar measure` would automatically benchmark changes.
But once a new release is out, CI fails because the current version has
been updated.
This is annoying. We need to figure out a better solution ... | diff --git a/benchmarks/engines/rust-memchr/Cargo.toml b/benchmarks/engines/rust-memchr/Cargo.toml
index 939f342..c605a9d 100644
--- a/benchmarks/engines/rust-memchr/Cargo.toml
+++ b/benchmarks/engines/rust-memchr/Cargo.toml
@@ -1,14 +1,18 @@
[package]
publish = false
name = "main"
-version = "2.6.0" # should match... | 1 | 6 | 2 |
1b8d5c89688b3358630f6fe4b972f5819b204af9 | Andrew Gallant | 2023-08-29T14:26:17 | api: gate 'into_owned' on 'alloc' feature
We did this for the forward case but apparently didn't follow through
for the reverse case.
We also simplify the endianness diagnostic test. | diff --git a/src/memmem/mod.rs b/src/memmem/mod.rs
index 2dadf4f..1a2a7e1 100644
--- a/src/memmem/mod.rs
+++ b/src/memmem/mod.rs
@@ -336,7 +336,7 @@ impl<'h, 'n> FindRevIter<'h, 'n> {
/// this copies the needle.
///
/// This is only available when the `std` feature is enabled.
- #[cfg(feature = "std")... | 2 | 4 | 8 |
2a58d261199b27e0dafaa8c91e7ea1f03d091d49 | Andrew Gallant | 2023-08-29T14:25:58 | fuzz: update dependencies | diff --git a/fuzz/Cargo.lock b/fuzz/Cargo.lock
index 700aecf..014605f 100644
--- a/fuzz/Cargo.lock
+++ b/fuzz/Cargo.lock
@@ -4,29 +4,49 @@ version = 3
[[package]]
name = "arbitrary"
-version = "1.0.0"
+version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "698b65a961a9d730f... | 1 | 33 | 7 |
46620054ff25b16d22e6e7ab563a6bde6791ee60 | Alex Touchet | 2023-08-28T22:38:38 | cargo: add rust-version to Cargo.toml
Now that our MSRV is high enough, we can set this.
PR #131 | diff --git a/Cargo.toml b/Cargo.toml
index 8d505c3..17c9f59 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -11,6 +11,7 @@ keywords = ["memchr", "char", "scan", "strchr", "string"]
license = "Unlicense OR MIT"
exclude = ["/bench", "/benchmarks", "/.github", "/fuzz", "/scripts", "/tmp"]
edition = "2021"
+rust-version = "... | 1 | 1 | 0 |
5af6e98718bd16b77eae3a05a28531187b3a27f7 | Andrew Gallant | 2023-08-28T15:58:00 | benchmarks: fix memchr version | diff --git a/benchmarks/engines/rust-memchr/Cargo.lock b/benchmarks/engines/rust-memchr/Cargo.lock
index 20aa424..4058cc6 100644
--- a/benchmarks/engines/rust-memchr/Cargo.lock
+++ b/benchmarks/engines/rust-memchr/Cargo.lock
@@ -14,28 +14,28 @@ version = "1.6.0"
source = "registry+https://github.com/rust-lang/crates.i... | 2 | 8 | 8 |
abcc473fac5bad3d5571ab59abb63bae525d403d | Guillaume Gomez | 2023-07-14T16:42:44 | docs.rs: add --generate-link-to-definition flag
This provides jump-to-definition while browsing
the source code in rustdoc output.
PR #128 | diff --git a/Cargo.toml b/Cargo.toml
index 532f253..61a19ee 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -61,3 +61,6 @@ debug = true
[profile.test]
opt-level = 3
debug = true
+
+[package.metadata.docs.rs]
+rustdoc-args = ["--generate-link-to-definition"] | 1 | 3 | 0 |
54c893176860c15cb41be03412ab0bc30f20df25 | gramar | 2023-02-13T14:03:41 | impl: add compile time cpu feature detection when `no_std`
This permits one to run the AVX memchr routines on x86-64 even when
'std' is not enabled. Probably something similar should be done for
memmem, but I think I have to insist on its conditional compilation
being simplified/centralized first.
Closes #120 | diff --git a/src/memchr/x86/mod.rs b/src/memchr/x86/mod.rs
index aec35db..51450f7 100644
--- a/src/memchr/x86/mod.rs
+++ b/src/memchr/x86/mod.rs
@@ -2,7 +2,7 @@ use super::fallback;
// We only use AVX when we can detect at runtime whether it's available, which
// requires std.
-#[cfg(feature = "std")]
+#[cfg(any(fe... | 1 | 14 | 6 |
7af67ce25998d7e91c349f39eb3e38efcc5d5e8f | Nathan West | 2023-05-08T21:23:26 | impl: improve `FindIter`
Basically, use `?` to pretty massively simplify `next`. And also add a
`size_hint` method based on some sensible constraints.
Closes #123 | diff --git a/src/memmem/mod.rs b/src/memmem/mod.rs
index dc1d0f7..f4f6602 100644
--- a/src/memmem/mod.rs
+++ b/src/memmem/mod.rs
@@ -349,20 +349,30 @@ impl<'h, 'n> Iterator for FindIter<'h, 'n> {
type Item = usize;
fn next(&mut self) -> Option<usize> {
- if self.pos > self.haystack.len() {
- ... | 1 | 24 | 14 |
e49a1b89ea8c7617de2e3447c356f7813d0a88e9 | Djordje Pepic | 2023-02-09T15:52:42 | memmem: add new HeuristicFrequencyRank
This makes it possible for the caller to provide their own ranking
function for individual bytes. This can potentially speed up searches if
one has a better guess than the default for the frequency distribution
of bytes in a particular haystack.
There is a lot of ceremony here, ... | diff --git a/bench/src/memmem/byterank.rs b/bench/src/memmem/byterank.rs
new file mode 100644
index 0000000..5598f3e
--- /dev/null
+++ b/bench/src/memmem/byterank.rs
@@ -0,0 +1,116 @@
+use criterion::Criterion;
+use memchr::memmem::HeuristicFrequencyRank;
+
+use crate::define;
+
+pub(crate) fn all(c: &mut Criterion) {
... | 8 | 261 | 30 |
2879561dba1b1684d17efb2ecb026c0edac4fa85 | Alex Touchet | 2022-05-04T18:52:37 | cargo: use SPDX license format in benchmark crate too
PR #110 | diff --git a/bench/Cargo.toml b/bench/Cargo.toml
index 947a964..91500ba 100644
--- a/bench/Cargo.toml
+++ b/bench/Cargo.toml
@@ -6,7 +6,7 @@ authors = ["Andrew Gallant <jamslam@gmail.com>"]
description = "Criterion benchmark suite for memchr."
homepage = "https://github.com/BurntSushi/memchr"
repository = "https://g... | 1 | 1 | 1 |
1ea11a9e28c735434063386988bcf8a8f0baf66e | Alex Touchet | 2022-05-04T13:08:01 | cargo: use SPDX license format
PR #109 | diff --git a/Cargo.toml b/Cargo.toml
index 03f126c..959daed 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -8,7 +8,7 @@ homepage = "https://github.com/BurntSushi/memchr"
repository = "https://github.com/BurntSushi/memchr"
readme = "README.md"
keywords = ["memchr", "char", "scan", "strchr", "string"]
-license = "Unlicen... | 1 | 1 | 1 |
b516165fe01acac5fb7570e2ed7f7465783bfbd4 | Ben Kimock | 2022-01-10T06:03:46 | tests: generate prefilter tests lazily
Generating all the prefilter test cases at once caused memory usage to
spike up to ~7.1 GB. This lazy implementation sees ~100 MB peak.
More specifically, this crate always OOMs in crater due to the sandbox
limits. In fact, its test suite can hit a peak memory usage of ~7.1 GB
w... | diff --git a/src/memmem/prefilter/mod.rs b/src/memmem/prefilter/mod.rs
index 07c4519..015d3b2 100644
--- a/src/memmem/prefilter/mod.rs
+++ b/src/memmem/prefilter/mod.rs
@@ -431,7 +431,7 @@ pub(crate) mod tests {
/// (Currently, we take the approach of massaging tests to be valid
/// instead of rejecti... | 1 | 35 | 34 |
1769cd6e93d25fe56f07b576e9bc7bb499ff4689 | Mike Hommey | 2021-11-16T11:08:08 | api: add Find{,Rev}Iter::into_owned
`memmem::Finder::new(needle).into_owned().find_iter(haystack)` returns
a `FindIter` that borrows the `Finder`. That `Finder` owns a copy of
the needle.
`memmem::find_iter(haystack, needle)` returns a `FindIter` that owns a
`Finder` that borrows the needle.
There is currently no wa... | diff --git a/src/memmem/mod.rs b/src/memmem/mod.rs
index 33e4083..e1cd1ae 100644
--- a/src/memmem/mod.rs
+++ b/src/memmem/mod.rs
@@ -324,6 +324,24 @@ impl<'h, 'n> FindIter<'h, 'n> {
let prestate = finder.searcher.prefilter_state();
FindIter { haystack, prestate, finder, pos: 0 }
}
+
+ /// Conv... | 1 | 35 | 0 |
d04ceb32640bab64455770326c1fff6af9e3bf1f | Evan Jones | 2021-09-22T13:16:49 | doc: find_iter, rfind_iter return non-overlapping matches
The documentation for FindIter and FindRevIter already include
this detail. However, it was not immediately clear to me from
the documentation what find_iter and rfind_iter do about
overlapping matches. This commit resolves that confusion by addiing
"non-overla... | diff --git a/src/memmem/mod.rs b/src/memmem/mod.rs
index 5e0e6d3..33e4083 100644
--- a/src/memmem/mod.rs
+++ b/src/memmem/mod.rs
@@ -160,7 +160,8 @@ mod wasm;
#[cfg(all(not(miri), target_arch = "x86_64", memchr_runtime_simd))]
mod x86;
-/// Returns an iterator over all occurrences of a substring in a haystack.
+///... | 1 | 4 | 3 |
3d405e85a277198d99149a48ee50467da3f71e9e | Andrew Gallant | 2021-05-06T14:09:36 | bench: update to sliceslice 0.3.0
And now that their API doesn't require a Box<[u8]>, we can make the
oneshot implementation a bit better. We simplify other constructions
where possible too. | diff --git a/bench/Cargo.toml b/bench/Cargo.toml
index 644bf0b..f73da47 100644
--- a/bench/Cargo.toml
+++ b/bench/Cargo.toml
@@ -23,5 +23,5 @@ criterion = "0.3.3"
memchr = { version = "*", path = ".." }
libc = "0.2.81"
regex = "1.4.5"
-sliceslice = "0.2.1"
+sliceslice = "0.3.0"
twoway = "0.2.1"
diff --git a/bench/s... | 3 | 15 | 12 |
3e1e3898247db48a8ef2a7aac0e5373df6c78561 | Andrew Gallant | 2021-05-01T14:17:51 | doc: some minor internal doc touchups | diff --git a/src/memmem/genericsimd.rs b/src/memmem/genericsimd.rs
index 2417f91..28bfdab 100644
--- a/src/memmem/genericsimd.rs
+++ b/src/memmem/genericsimd.rs
@@ -195,7 +195,9 @@ pub(crate) unsafe fn fwd_find<V: Vector>(
}
/// Search for an occurrence of two rare bytes from the needle in the chunk
-/// pointed to... | 1 | 4 | 2 |
1f1aaf3f76e4db56ac3d7b04d2fb9543b03dceaf | Stuart Carnie | 2021-01-04T13:05:56 | bench: update libc and criterion crates to latest
I guess the older 0.2.x version of Criterion stopped working after
Rust 1.47? Yikes.
PR #80 | diff --git a/bench/Cargo.lock b/bench/Cargo.lock
index 6b29a4f..0d8fd1f 100644
--- a/bench/Cargo.lock
+++ b/bench/Cargo.lock
@@ -1,544 +1,653 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
-[[package]]
-name = "arrayvec"
-version = "0.4.11"
-source = "registry+https://gi... | 3 | 340 | 228 |
3f9b97728169d0cb0c8c044795393e83ee41ab95 | Martin Kröning | 2020-10-27T15:18:31 | build: only enable simd on targets which feature SSE
While odd, it is possible for x86_64 to not have SSE enabled. In that
case, we want to avoid enabling the explicit SIMD options, as it will
result in a compilation failure. We address this by checking the CPU
target features at compile time. If SSE isn't in them, th... | diff --git a/build.rs b/build.rs
index 4ae3184..e07ad6f 100644
--- a/build.rs
+++ b/build.rs
@@ -5,12 +5,19 @@ fn main() {
enable_libc();
}
-// This adds various simd cfgs if this compiler supports it.
+// This adds various simd cfgs if this compiler and target support it.
//
// This can be disabled with RUST... | 1 | 15 | 2 |
10f11fbeaaec9d1c892be30718604a09b6622e8e | Count-Count | 2020-09-09T14:29:04 | bench: run libc benchmarks on non-x86 environments
It's not clear why libc benchmarks were only being run in x86_64
environments, so this removes that gate. In particular, we want to
be able to compare it with non-x86_64 SIMD implementations of
memchr (such as neon).
PR #75 | diff --git a/bench/Cargo.toml b/bench/Cargo.toml
index 17e90af..71d049b 100644
--- a/bench/Cargo.toml
+++ b/bench/Cargo.toml
@@ -19,9 +19,7 @@ path = "src/bench.rs"
[dependencies]
criterion = "0.2"
memchr = { version = "*", path = ".." }
-
-[target.'cfg(target_arch = "x86_64")'.dependencies.libc]
-version = "0.2.18"... | 3 | 31 | 40 |
68839652824277094f9752f3b216a30260dc613f | Andrew Gallant | 2020-02-21T19:46:16 | tests: run some tests with --no-default-features
Previously, this wouldn't compile. But since it's a supported
configuration, we should try to run *some* tests.
Fixes #71 | diff --git a/src/lib.rs b/src/lib.rs
index d5ddada..fed7108 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -36,7 +36,7 @@ compile_error!("memchr currently not supported on non-32 or non-64 bit");
#[cfg(feature = "std")]
extern crate core;
-#[cfg(all(test, not(miri)))]
+#[cfg(all(test, all(not(miri), feature = "std")))... | 1 | 3 | 3 |
72ad872a3148d858d2645386f4d6c3aab60a5d1c | Lucas Desgouilles | 2020-02-12T14:48:28 | cfg: support MIRI by using `naive` implementations
MIRI has problems dealing with SIMD or raw pointers, so we cannot use
the fallback or SIMD accelerated versions. Instead, we fall back to the
"naive" version using iterators.
Ideally, this is a temporary measure to make more things work with MIRI
in practice. In... | diff --git a/src/lib.rs b/src/lib.rs
index 8b27643..aca67c0 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -53,7 +53,7 @@ mod iter;
mod naive;
#[cfg(test)]
mod tests;
-#[cfg(all(target_arch = "x86_64", memchr_runtime_simd))]
+#[cfg(all(not(miri), target_arch = "x86_64", memchr_runtime_simd))]
mod x86;
/// An iterat... | 1 | 67 | 16 |
b74f6065b54661f499e6a5428b09d8382e9d3b6d | Christian Vallentin | 2020-02-11T21:24:57 | doc: fix misspelling
PR #66 | diff --git a/src/lib.rs b/src/lib.rs
index 61f5d85..8b27643 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -205,7 +205,7 @@ pub fn memchr2(needle1: u8, needle2: u8, haystack: &[u8]) -> Option<usize> {
/// Like `memchr`, but searches for any of three bytes instead of just one.
///
/// This returns the index correspondin... | 1 | 2 | 2 |
b00211b072b2a8824dd073f6b8a58603ae23d738 | Andrew Gallant | 2020-01-10T20:42:26 | deps: update to quickcheck 0.9 | diff --git a/Cargo.toml b/Cargo.toml
index 909e496..07f247e 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -27,7 +27,7 @@ use_std = []
libc = { version = "0.2.18", default-features = false, optional = true }
[dev-dependencies]
-quickcheck = { version = "0.8", default-features = false }
+quickcheck = { version = "0.9",... | 1 | 1 | 1 |
144016254a0b2a91c5d3e27d0f814c82b2eb2b25 | Andrew Gallant | 2020-01-10T20:41:50 | tidy: clean up code due to MSRV bump
We can now use some of the convenience functions on raw pointers instead
of rolling our own. | diff --git a/src/fallback.rs b/src/fallback.rs
index 69d532c..8bc32b2 100644
--- a/src/fallback.rs
+++ b/src/fallback.rs
@@ -3,7 +3,6 @@
// get auto-vectorized.
use core::cmp;
-use core::ptr;
use core::usize;
#[cfg(target_pointer_width = "16")]
@@ -59,25 +58,25 @@ pub fn memchr(n1: u8, haystack: &[u8]) -> Optio... | 3 | 33 | 52 |
8ca81f32109d7f5ef1e5c0a2a28a5369d1a8eb95 | David Flemström | 2019-08-14T21:31:19 | error: tweak the compiler error
Now that we support 16-bit targets, remove the compilation error on
16-bit targets. | diff --git a/src/lib.rs b/src/lib.rs
index 3f84878..216c7ed 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -25,9 +25,13 @@ instead of one. Similarly for `memchr3`.
#![deny(missing_docs)]
#![doc(html_root_url = "https://docs.rs/memchr/2.0.0")]
-// Supporting 16-bit would be fine. If you need it, please submit a bug rep... | 1 | 7 | 3 |
3451643ba3c9f5fc17e5cab7e45d130bb4d0828d | David Flemström | 2019-08-14T21:30:14 | fallback: support 16-bit targets
Closes #55 | diff --git a/src/fallback.rs b/src/fallback.rs
index 3fcfc89..69d532c 100644
--- a/src/fallback.rs
+++ b/src/fallback.rs
@@ -6,6 +6,9 @@ use core::cmp;
use core::ptr;
use core::usize;
+#[cfg(target_pointer_width = "16")]
+const USIZE_BYTES: usize = 2;
+
#[cfg(target_pointer_width = "32")]
const USIZE_BYTES: usize... | 1 | 3 | 0 |
a991cc9b16900cbf70647e5ad97965f5ec2eafe6 | Timo | 2020-01-10T20:21:02 | doc: clarify bitshift amounts in sse2 pseudocode
Shifts are normally in bits, but in the pseudo code for SIMD, it's
probably clearer to use bytes. However, this may be surprising
to some, so we add a clarifying comment.
PR #60 | diff --git a/src/x86/sse2.rs b/src/x86/sse2.rs
index 2c667b1..ac24f5a 100644
--- a/src/x86/sse2.rs
+++ b/src/x86/sse2.rs
@@ -26,6 +26,8 @@ pub unsafe fn memchr(n1: u8, haystack: &[u8]) -> Option<usize> {
// and can be expressed straight-forwardly in pseudo code:
//
// needle = (n1 << 15) | (n1 << 14)... | 1 | 2 | 0 |
3c4b62387609384f547d49ca482934e5a01a095c | Timo | 2020-01-10T20:19:27 | doc: expand docs for `memr?chr[23]`
PR #62 | diff --git a/src/lib.rs b/src/lib.rs
index b828475..3f84878 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -160,7 +160,28 @@ pub fn memchr(needle: u8, haystack: &[u8]) -> Option<usize> {
}
}
-/// Like `memchr`, but searches for two bytes instead of one.
+/// Like `memchr`, but searches for either of two bytes inst... | 1 | 88 | 4 |
b5c5cfe37207b00494597ac14a23e826fe8e59b1 | Michal Srb | 2019-10-31T12:16:33 | simd: remove redundant block in memchr3
In the sse2 and avx implementation of memchr3.
The memchr3 steps by two vector-sizes at time. When a match was found in
one of them, it would check the first one first, then the second one and
then the second one again.
It wasn't causing any incorrect behavior, but did e... | diff --git a/src/x86/avx.rs b/src/x86/avx.rs
index c3fd56b..776d11e 100644
--- a/src/x86/avx.rs
+++ b/src/x86/avx.rs
@@ -222,14 +222,6 @@ pub unsafe fn memchr3(
return Some(at + forward_pos3(mask1, mask2, mask3));
}
- at += VECTOR_SIZE;
- let mask1 = _mm256_movemask... | 2 | 0 | 16 |
665fffcc9506ac1cd93339470d2ca4b018e648c6 | Andrew Gallant | 2019-07-11T14:49:11 | deps: update benchmark dependencies | diff --git a/bench/Cargo.lock b/bench/Cargo.lock
index 888ca7b..6b29a4f 100644
--- a/bench/Cargo.lock
+++ b/bench/Cargo.lock
@@ -2,7 +2,7 @@
# It is not intended for manual editing.
[[package]]
name = "arrayvec"
-version = "0.4.10"
+version = "0.4.11"
source = "registry+https://github.com/rust-lang/crates.io-index"... | 1 | 188 | 137 |
aedc93559c0532bf5c0605aa9b6a96c89cfb3858 | Johann Tuffe | 2019-07-07T20:16:41 | simd: speed up position extraction
By simplifying forward_pos and reverse_pos by ORing masks.
This works because we always want the first matching position,
and ORing the masks won't change the result with respect to
extracting the number of trailing zeroes. (And similarly for the
reverse direction.)
This has t... | diff --git a/bench/Cargo.lock b/bench/Cargo.lock
index eba2b4b..888ca7b 100644
--- a/bench/Cargo.lock
+++ b/bench/Cargo.lock
@@ -171,10 +171,6 @@ name = "libc"
version = "0.2.48"
source = "registry+https://github.com/rust-lang/crates.io-index"
-[[package]]
-name = "memchr"
-version = "2.1.3"
-
[[package]]
name = ... | 3 | 13 | 85 |
b6f46c9962d8e813a4fe66fd06997200a8a615e8 | Felix Rabe | 2019-07-07T19:22:36 | doc: clarify comment wording
PR #54 | diff --git a/src/x86/mod.rs b/src/x86/mod.rs
index 6599da3..b8bdd7b 100644
--- a/src/x86/mod.rs
+++ b/src/x86/mod.rs
@@ -59,7 +59,7 @@ macro_rules! ifunc {
}}
}
-// When std isn't enable (which provides runtime CPU feature detection), or if
+// When std isn't available to provide runtime CPU feature detection, ... | 1 | 1 | 1 |
0cef3c3c59661379e6a4ad4d182c5ffb0e76116a | Andrew Gallant | 2019-02-12T01:40:58 | bench: update Cargo.lock | diff --git a/bench/Cargo.lock b/bench/Cargo.lock
index 8410e55..eba2b4b 100644
--- a/bench/Cargo.lock
+++ b/bench/Cargo.lock
@@ -1,17 +1,11 @@
+# This file is automatically @generated by Cargo.
+# It is not intended for manual editing.
[[package]]
-name = "aho-corasick"
-version = "0.6.8"
+name = "arrayvec"
+version =... | 1 | 197 | 394 |
6ebcd7a4eab6320439cf888a9104756e8be28d91 | bluss | 2018-11-24T16:48:20 | ifunc: use static with AtomicPtr
This replaces the use of `static mut`, because there's a faint rumbling
in the distance that static mut is to be avoided[1]. It seems to be a
problem when we take *mutable* references to the static, and this code
didn't. Therefore, this is only done out of an abundance of caution;
ther... | diff --git a/src/x86/mod.rs b/src/x86/mod.rs
index a1b4b86..6599da3 100644
--- a/src/x86/mod.rs
+++ b/src/x86/mod.rs
@@ -31,30 +31,30 @@ mod sse2;
macro_rules! ifunc {
($fnty:ty, $name:ident, $haystack:ident, $($needle:ident),+) => {{
use std::mem;
- use std::sync::atomic::{AtomicUsize, Ordering};... | 1 | 11 | 11 |
1769eefda03acc96668cda8106afebb0f153335e | Andrew Gallant | 2019-02-12T00:28:52 | libc: simplify use of libc
This moves the libc config knobs into build.rs, which makes conditional
compilation on libc a bit easier and also centralizes the logic for
determining whether to use libc in one place. | diff --git a/build.rs b/build.rs
index f245ada..35f06f9 100644
--- a/build.rs
+++ b/build.rs
@@ -11,10 +11,15 @@ fn main() {
}
};
enable_simd_optimizations(version);
+ enable_libc();
}
+// This adds various simd cfgs if this compiler supports it.
+//
+// This can be disabled with RUSTFLAGS="--c... | 2 | 51 | 19 |
d01b35e9f903c888d23c628c7631cc6912284869 | Andrew Gallant | 2019-01-19T13:12:24 | deps: remove version_check
memchr is a core crate and should ideally have as few dependencies as
possible. | diff --git a/Cargo.toml b/Cargo.toml
index e83d783..8588e54 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -27,9 +27,6 @@ use_std = ["libc", "libc/use_std"]
cfg-if = "0.1.5"
libc = { version = "0.2.18", default-features = false, optional = true }
-[build-dependencies]
-version_check = "0.1.4"
-
[dev-dependencies]
qu... | 2 | 71 | 13 |
07cf258ed0cf4169a264ee5d3ddc819cbda65012 | Andrew Gallant | 2019-01-19T13:12:05 | deps: bump quickcheck to 0.8 | diff --git a/Cargo.toml b/Cargo.toml
index 65b1fe7..e83d783 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -31,7 +31,7 @@ libc = { version = "0.2.18", default-features = false, optional = true }
version_check = "0.1.4"
[dev-dependencies]
-quickcheck = { version = "0.7", default-features = false }
+quickcheck = { versi... | 1 | 1 | 1 |
09b2a2dfe61e1905112189dea2a6e483971d14e4 | HeroicKatora | 2019-01-08T12:39:08 | doc: fix typo
This is a duplicate of typo fixed in #40, the comment seems to also have
been a copy from the very similar method.
PR #47 | diff --git a/src/lib.rs b/src/lib.rs
index f1d8f0f..b2694ff 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -222,7 +222,7 @@ pub fn memchr3(
///
/// While this is operationally the same as something like
/// `haystack.iter().rposition(|&b| b == needle)`, `memrchr` will use a highly
-/// optimized routine that can be up ... | 1 | 1 | 1 |
6b6a7648fab9657b39d4633abe403cffedec3e10 | jethrogb | 2018-12-11T12:24:14 | platform: add support for x86_64-fortanix-unknown-sgx target
Adding support in this case basically just means that we avoid
using libc's implementation of memchr when we might otherwise
use it on platforms that support it. | diff --git a/src/lib.rs b/src/lib.rs
index 1208326..f1d8f0f 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -46,6 +46,7 @@ pub use iter::{Memchr, Memchr2, Memchr3};
#[cfg(all(
feature = "libc",
not(target_arch = "wasm32"),
+ not(target_env = "sgx"),
))]
mod c;
#[allow(dead_code)]
@@ -143,6 +144,7 @@ pub fn... | 1 | 3 | 0 |
451d16d440928b5547b92317fd83fc4c937b7b91 | ethanpailes | 2018-10-31T11:04:27 | doc: s/master/faster
PR #40 | diff --git a/src/lib.rs b/src/lib.rs
index cd32a64..1208326 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -118,7 +118,7 @@ pub fn memrchr3_iter(
///
/// While this is operationally the same as something like
/// `haystack.iter().position(|&b| b == needle)`, `memchr` will use a highly
-/// optimized routine that can be... | 1 | 1 | 1 |
ec7bdfe4094fa62740b65ee0ed15e70887cebe2e | Igor Gnatenko | 2018-10-27T20:44:20 | exclude CI files | diff --git a/Cargo.toml b/Cargo.toml
index 7b7166b..7092549 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -9,6 +9,7 @@ repository = "https://github.com/BurntSushi/rust-memchr"
readme = "README.md"
keywords = ["memchr", "char", "scan", "strchr", "string"]
license = "Unlicense/MIT"
+exclude = ["/ci/*", "/.travis.yml", "... | 1 | 1 | 0 |
4ee2398d1ff6edd9cc037ccb8fc7c63ce62b8e8f | Andrew Gallant | 2018-09-17T21:41:51 | fallback: fix unaligned read
This commit fixes a bug that caused undefined behavior by doing an
aligned read when an unaligned read was intended. In particular, we were
casting a `*const u8` to a `*const usize` and then reading its contents
to a `*mut usize`. The correct implementation is to reverse this such
that we ... | diff --git a/src/fallback.rs b/src/fallback.rs
index 11fad1f..3fcfc89 100644
--- a/src/fallback.rs
+++ b/src/fallback.rs
@@ -334,7 +334,7 @@ unsafe fn ptr_sub(ptr: *const u8, amt: usize) -> *const u8 {
unsafe fn read_unaligned_usize(ptr: *const u8) -> usize {
let mut n: usize = 0;
- ptr::copy_nonoverlapping(... | 2 | 2 | 2 |
4d4de5c18d9e97a192f6a4e2449f6937d818f66e | Andrew Gallant | 2018-09-11T21:34:33 | tests: increase coverage dramatically
This commit updates the tests to increase their coverage dramatically.
They were influenced by my experimenting with the existing tests by
introducing subtle bugs into the memchr implementations, and witnessing
with horror at the test suite continuing to pass.
We increase by cove... | diff --git a/src/tests/iter.rs b/src/tests/iter.rs
index a24d6e6..b267c80 100644
--- a/src/tests/iter.rs
+++ b/src/tests/iter.rs
@@ -1,32 +1,32 @@
use std::prelude::v1::*;
-use tests::MEMCHR_TESTS;
+use tests::memchr_tests;
use {Memchr, Memchr2, Memchr3};
#[test]
fn memchr1_iter() {
- for test in MEMCHR_TEST... | 3 | 196 | 91 |
638b4861f9f107de7e9c8a00e657855ba071cb7c | Andrew Gallant | 2018-09-11T00:00:07 | version: set cfg's on Rust 1.27 or newer
We'll use these configs to enable use of vendor intrinsics on stable
Rust compilers to support it. To check the version, we use the
lightweight version_check crate. | diff --git a/Cargo.toml b/Cargo.toml
index 752e396..5ebb9bd 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -25,6 +25,9 @@ use_std = ["libc", "libc/use_std"]
[dependencies]
libc = { version = "0.2.18", default-features = false, optional = true }
+[build-dependencies]
+version_check = "0.1.4"
+
[dev-dependencies]
quic... | 3 | 30 | 0 |
e2935e3ff08a36e69ff9e951b1bf87f6ecb4e447 | Andrew Gallant | 2018-09-10T00:02:59 | memchr: tweak repeat_byte
This patch is from the standard library. | diff --git a/src/lib.rs b/src/lib.rs
index 00fa855..7907ad4 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -30,6 +30,11 @@ use std::cmp;
#[cfg(not(feature = "use_std"))]
use core::cmp;
+#[cfg(feature = "use_std")]
+use std::usize;
+#[cfg(not(feature = "use_std"))]
+use core::usize;
+
const LO_U64: u64 = 0x01010101010... | 1 | 9 | 9 |
8a2f4da29a0d4e1fadb4e292a2e7f87be033879d | Andrew Gallant | 2018-08-25T14:21:57 | deps: update to quickcheck 0.7 | diff --git a/Cargo.toml b/Cargo.toml
index 1889b5b..f0c4088 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -26,7 +26,7 @@ use_std = ["libc", "libc/use_std"]
libc = { version = "0.2.18", default-features = false, optional = true }
[dev-dependencies]
-quickcheck = { version = "0.6", default-features = false }
+quickchec... | 1 | 1 | 1 |
c9a7e713d65448541ca373734f3cd18e11d29c1d | Bruce Mitchener | 2018-03-03T16:01:27 | doc: Memchr3::new() creates a Memchr3, not Memchr2 | diff --git a/src/lib.rs b/src/lib.rs
index df148dd..00fa855 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -337,7 +337,7 @@ pub struct Memchr3<'a> {
}
impl<'a> Memchr3<'a> {
- /// Create a new Memchr2 that's initialized to zero with a haystack
+ /// Create a new `Memchr3` that's initialized to zero with a haysta... | 1 | 1 | 1 |
e233ae66e6bb782d42c5445a59269712888c7dfb | Bruce Mitchener | 2018-03-03T16:01:09 | cleanup: fix needless borrows
`self.haystack` here is already a reference, so no need to take
a reference to it. | diff --git a/src/lib.rs b/src/lib.rs
index a291b28..df148dd 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -125,7 +125,7 @@ impl<'a> Iterator for Memchr<'a> {
type Item = usize;
fn next(&mut self) -> Option<usize> {
- iter_next!(self, memchr(self.needle, &self.haystack))
+ iter_next!(self, memchr... | 1 | 4 | 4 |
c36099e3f6d96239448bd8915671e11db112cd19 | Bruce Mitchener | 2018-03-03T15:31:33 | doc: fix spelling of initial and initialized | diff --git a/src/lib.rs b/src/lib.rs
index 764b87d..a291b28 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -337,7 +337,7 @@ pub struct Memchr3<'a> {
}
impl<'a> Memchr3<'a> {
- /// Create a new Memchr2 that's initalized to zero with a haystack
+ /// Create a new Memchr2 that's initialized to zero with a haystack
... | 1 | 2 | 2 |
49aadca6a9a74eec08a2b17beeb9967c44624429 | Igor Gnatenko | 2018-01-01T11:27:34 | bump quickcheck to 0.6 | diff --git a/Cargo.toml b/Cargo.toml
index 3e73e7e..1889b5b 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -26,7 +26,7 @@ use_std = ["libc", "libc/use_std"]
libc = { version = "0.2.18", default-features = false, optional = true }
[dev-dependencies]
-quickcheck = { version = "0.5", default-features = false }
+quickchec... | 1 | 1 | 1 |
49ab2eff61e55aa4240b1303d7affab75a845ec8 | Hoàng Đức Hiếu | 2018-01-01T07:13:18 | fallback: fix variable name in docstrings | diff --git a/src/lib.rs b/src/lib.rs
index 2d87ec7..764b87d 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -424,7 +424,7 @@ mod fallback {
contains_zero_byte, repeat_byte,
};
- /// Return the first index matching the byte `a` in `text`.
+ /// Return the first index matching the byte `x` in `text`.
... | 1 | 2 | 2 |
f0edf2485ff81a39bbac0c25ebae309f1cb36b00 | Volker Mische | 2017-11-30T13:44:48 | Make it compile on wasm32
The wasm32 target doesn't have a libc (it's empty), hence compile
memchr without libc for the wasm target. | diff --git a/src/lib.rs b/src/lib.rs
index d9560c7..2d87ec7 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -13,16 +13,16 @@ interface to the corresponding functions in `libc`.
#[macro_use]
extern crate std;
-#[cfg(feature = "libc")]
+#[cfg(all(feature = "libc", not(target_arch = "wasm32")))]
extern crate libc;
#[m... | 1 | 6 | 4 |
47c5d86187753ebc1f574f0f958615b8991749f8 | Igor Gnatenko | 2017-11-29T09:58:23 | bump quickcheck to 0.5 | diff --git a/Cargo.toml b/Cargo.toml
index 47af932..f15d524 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -26,7 +26,7 @@ use_std = ["libc", "libc/use_std"]
libc = { version = "0.2.18", default-features = false, optional = true }
[dev-dependencies]
-quickcheck = { version = "0.4.1", default-features = false }
+quickch... | 1 | 1 | 1 |
ffb4d3ce2152ff37b15eb414f85957f5d9057b07 | Andrew Gallant | 2017-10-21T12:04:23 | bump to 2.0.0 | diff --git a/Cargo.toml b/Cargo.toml
index 567a596..47af932 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "memchr"
-version = "1.0.2" #:version
+version = "2.0.0" #:version
authors = ["Andrew Gallant <jamslam@gmail.com>", "bluss"]
description = "Safe interface to memchr."
documentatio... | 2 | 2 | 1 |
e988ead2d8c42254598a224dc908a86da4b1a3f2 | Andrew Gallant | 2017-10-21T12:03:19 | style: wrap to 80 columns | diff --git a/src/lib.rs b/src/lib.rs
index c3f410e..fd07de5 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -335,7 +335,12 @@ pub struct Memchr3<'a> {
impl<'a> Memchr3<'a> {
/// Create a new Memchr2 that's initalized to zero with a haystack
- pub fn new(needle1: u8, needle2: u8, needle3: u8, haystack: &[u8]) -> ... | 1 | 68 | 27 |
954b99430cb2e48ae8fed654bfd292fe7459205b | bluss | 2017-08-05T22:30:48 | Fix and clarify size_hint test
Add one missing bound check and clarify the code slightly when testing
Memchr iterator's size_hint | diff --git a/src/lib.rs b/src/lib.rs
index b8b7a43..c3f410e 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1003,13 +1003,13 @@ mod tests {
// test that the size hint is within reasonable bounds
let needle = 0;
let mut iter = Memchr::new(needle, &data);
- let real_total = ... | 1 | 4 | 4 |
c50fe96c6c156e2c472fcd70ec1c164bf1105c2d | bluss | 2017-08-05T22:23:52 | Fix tests for Rust 1.12 | diff --git a/src/lib.rs b/src/lib.rs
index eba68ac..b8b7a43 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -511,7 +511,7 @@ mod tests {
($mod_name:ident, $memchr:path, $memrchr:path) => {
mod $mod_name {
use std::prelude::v1::*;
- use super::quickcheck;
+ use quickc... | 1 | 1 | 1 |
e93f4640d869d367d71e1281a7fcfab96a6b018c | bluss | 2017-08-05T22:12:44 | Add .size_hint() for the iterators
Includes a tests just for the Memchr iterator, asserting that the size
hint is within reasonable bounds. | diff --git a/src/lib.rs b/src/lib.rs
index 80f3d1b..eba68ac 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -126,6 +126,10 @@ impl<'a> Iterator for Memchr<'a> {
fn next(&mut self) -> Option<usize> {
iter_next!(self, memchr(self.needle, &self.haystack))
}
+
+ fn size_hint(&self) -> (usize, Option<usize... | 1 | 28 | 0 |
8313aebad08af00dbd7090114f2a70a1842b6f45 | bluss | 2017-08-05T21:11:35 | Fix Memchr iterators to use 0-based positions
These iterators by mistake were starting positions at 1, which disagrees
with convention and disagrees with common API (like Iterator::position
as well as slice indexing).
Fix all three iterators to use 0-based indexing. Compare with 0-based
iterator scans to verify the r... | diff --git a/src/lib.rs b/src/lib.rs
index 7faf323..80f3d1b 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1,6 +1,6 @@
/*!
-This crate defines two functions, `memchr` and `memrchr`, which expose a safe interface
-to the corresponding functions in `libc`.
+This crate defines two functions, `memchr` and `memrchr`, which e... | 1 | 171 | 62 |
3b94fdfdaa068f95a96719767c98ae0868f95dd5 | bluss | 2017-08-05T21:11:48 | Skip default features for quickcheck dev-dependency | diff --git a/Cargo.toml b/Cargo.toml
index 99ec414..567a596 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -26,7 +26,7 @@ use_std = ["libc", "libc/use_std"]
libc = { version = "0.2.18", default-features = false, optional = true }
[dev-dependencies]
-quickcheck = "0.4.1"
+quickcheck = { version = "0.4.1", default-featu... | 1 | 1 | 1 |
e31318062fdd736c0c8b14eae2861b1aa98b8518 | Amanieu d'Antras | 2017-10-11T18:59:20 | Make linking to libc optional | diff --git a/Cargo.toml b/Cargo.toml
index 29d4e81..3040043 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -19,11 +19,11 @@ name = "memchr"
bench = false
[features]
-default = ["use_std"]
-use_std = ["libc/use_std"]
+default = ["use_std", "libc"]
+use_std = ["libc", "libc/use_std"]
[dependencies]
-libc = { version ... | 2 | 23 | 11 |
0e5e16ccdf68cca45603136c1d195286b22c634a | cbreeden | 2017-06-16T19:09:08 | Remove dead code
It's not possible for `Memchar.rposition <= 0` so this branch is dead. | diff --git a/src/lib.rs b/src/lib.rs
index 587e7c4..2d58d1a 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -70,7 +70,6 @@ pub struct Memchr<'a> {
haystack: &'a [u8],
// The index
position: usize,
- rposition: usize,
}
impl<'a> Memchr<'a> {
@@ -80,7 +79,6 @@ impl<'a> Memchr<'a> {
needle: ... | 1 | 1 | 9 |
a6d69d72c809af312dc77f1ee6a4942c72cf34ea | Martin Geisler | 2017-07-24T22:10:10 | Add CI badges | diff --git a/Cargo.toml b/Cargo.toml
index 1748622..29d4e81 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -10,6 +10,10 @@ readme = "README.md"
keywords = ["memchr", "char", "scan", "strchr", "string"]
license = "Unlicense/MIT"
+[badges]
+travis-ci = { repository = "BurntSushi/rust-memchr" }
+appveyor = { repository =... | 1 | 4 | 0 |
55a27cf3d7585e38cfed2cb57f7be1e25ea9e883 | Ivan Enderlin | 2017-03-03T08:36:48 | Remove useless `return` statements. | diff --git a/src/lib.rs b/src/lib.rs
index 96c0db3..587e7c4 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -112,9 +112,9 @@ impl<'a> DoubleEndedIterator for Memchr<'a> {
if self.rposition > 0 {
//memrchr has been used once already.
self.rposition = self.rposition ... | 1 | 2 | 2 |
1d246106ad9402978187118326d422ea6c75711b | Andrew Gallant | 2017-01-04T01:43:11 | bump opt-level of 'cargo test' | diff --git a/Cargo.toml b/Cargo.toml
index 53e9d1e..ec4601d 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -23,3 +23,6 @@ libc = { version = "0.2.18", default-features = false }
[dev-dependencies]
quickcheck = "0.4.1"
+
+[profile.test]
+opt-level = 3 | 1 | 3 | 0 |
1b37466ed6f79fcc40692beccfd16b199830b147 | Chris Holcombe | 2016-10-13T15:08:39 | Modify DoubleEndedIterator to use rposition instead of just position | diff --git a/src/lib.rs b/src/lib.rs
index a071bd9..8dc6aaf 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -98,8 +98,13 @@ impl<'a> DoubleEndedIterator for Memchr<'a> {
Some(index) => {
// Move our internal position
self.haystack = self.haystack.split_at(index).0;
- ... | 1 | 23 | 2 |
c80cf9e78428acd652847f7e5779dfb7ea824e06 | Chris Holcombe | 2016-10-12T02:45:24 | Add iter implementation for memchr2 and memchr3
Added iterators for memchr2 and 3. Also added an
implementation for DoubleEndedIterator for memchr. | diff --git a/src/lib.rs b/src/lib.rs
index f68e3a5..90330b7 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1,6 +1,7 @@
-//! This crate defines two functions, `memchr` and `memrchr`, which expose a safe interface
-//! to the corresponding functions in `libc`.
-//!
+/*!
+This crate defines two functions, `memchr` and `memr... | 1 | 149 | 8 |
77c71de8b15ec9883442ac75049d48930fc39b58 | Chris Holcombe | 2016-10-08T20:43:48 | Implement Iterator for memchr | diff --git a/src/lib.rs b/src/lib.rs
index c340d5b..f68e3a5 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1,7 +1,6 @@
-/*!
-This crate defines two functions, `memchr` and `memrchr`, which expose a safe interface
-to the corresponding functions in `libc`.
-*/
+//! This crate defines two functions, `memchr` and `memrchr`,... | 1 | 73 | 36 |
9a0ad22e443a542304cfc9d8c34e24c128870493 | bluss | 2016-08-24T19:43:28 | memrchr: Use a conditional instead of subtracting a complicated min
This makes the critical calculation easier to understand. | diff --git a/src/lib.rs b/src/lib.rs
index 95ddc3a..4250dd9 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -310,7 +310,7 @@ mod fallback {
let end_align = (ptr as usize + len) & (USIZE_BYTES - 1);
let mut offset;
if end_align > 0 {
- offset = len - cmp::min(end_align, len);
+ ... | 1 | 1 | 1 |
ebe693c39bfd92e0f74371eaa85eab2666713dbb | bluss | 2016-08-24T11:58:43 | Double up tests so that they test native and fallback memr?chr | diff --git a/src/lib.rs b/src/lib.rs
index a8f3744..95ddc3a 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -238,8 +238,8 @@ pub fn memchr3(
}
#[allow(dead_code)]
-#[cfg(all(not(target_os = "linux"),
- any(target_pointer_width = "32", target_pointer_width = "64")))]
+#[cfg(any(test, all(not(target_os = "linux"... | 1 | 123 | 139 |
ac0a94d5b386ac707217f81061ad4f676e645c32 | bluss | 2016-08-24T11:58:43 | Add debug assertions that pointer + offset is aligned | diff --git a/src/lib.rs b/src/lib.rs
index 8bf4b70..a8f3744 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -275,6 +275,7 @@ mod fallback {
if len >= 2 * USIZE_BYTES {
while offset <= len - 2 * USIZE_BYTES {
+ debug_assert_eq!((ptr as usize + offset) % USIZE_BYTES, 0);
... | 1 | 2 | 0 |
d31a572a9790807fbd3ef2a3aa53e4ea84bfe0fd | bluss | 2016-08-24T11:58:43 | memrchr: Fix alignment error in memrchr's fallback.
The fallback did not compute the offset correctly. It was intentioned to
land on usize-aligned addresses but did not. This resulted in a SIGBUS
on an ARMv7 platform!
I think like this, if we have a slice with pointer `ptr` and length
`len`, we want to find the last ... | diff --git a/src/lib.rs b/src/lib.rs
index c340d5b..8bf4b70 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -309,7 +309,7 @@ mod fallback {
let end_align = (ptr as usize + len) & (USIZE_BYTES - 1);
let mut offset;
if end_align > 0 {
- offset = len - cmp::min(USIZE_BYTES - end_align, le... | 1 | 1 | 1 |
62eae0de4a5d231467b27ca6719f000c63f4edf2 | Andrew Gallant | 2016-04-02T22:40:05 | Add a couple inline(always) annotations.
These are necessary to get memchr to inline, which can reduce a fair
amount of constant overhead. | diff --git a/src/lib.rs b/src/lib.rs
index 4d0e345..c340d5b 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -71,11 +71,13 @@ fn repeat_byte(b: u8) -> usize {
/// let haystack = b"the quick brown fox";
/// assert_eq!(memchr(b'k', haystack), Some(8));
/// ```
+#[inline(always)] // reduces constant overhead
pub fn memchr(... | 1 | 4 | 0 |
f518f639ef9bf0962d334a5a88fe713609b5d6ac | Andrew Gallant | 2016-04-02T22:39:40 | Add a benchmark.
See: https://github.com/rust-lang-nursery/regex/issues/184 | diff --git a/Cargo.toml b/Cargo.toml
index f4de962..8fe08c6 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -12,6 +12,7 @@ license = "Unlicense/MIT"
[lib]
name = "memchr"
+bench = false
[dependencies]
libc = "0.2.4"
diff --git a/benches/bench.rs b/benches/bench.rs
index d77f879..949b222 100644
--- a/benches/bench.r... | 2 | 25 | 0 |
f7cebf926df9d75ee38609776850c8d6d269aa9a | Andrew Gallant | 2016-02-14T22:14:55 | fix for fallback impls | diff --git a/src/lib.rs b/src/lib.rs
index 2d70898..4d0e345 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -240,7 +240,7 @@ mod fallback {
use std::cmp;
use super::{
LO_U64, HI_U64, LO_USIZE, HI_USIZE, USIZE_BYTES,
- contains_zero_bytes, repeat_byte,
+ contains_zero_byte, repeat_byte,
... | 1 | 1 | 1 |
19d0452faa2b50ef2a75b4d2d0a8dce96b8b7a55 | Andrew Gallant | 2016-02-14T21:36:09 | Add memchr3 because why not?
Factor out some of the common code that was previously only used in the
fallback memchr implementations, but is now used in memchr2 and memchr3. | diff --git a/benches/bench.rs b/benches/bench.rs
index e78cb4c..d77f879 100644
--- a/benches/bench.rs
+++ b/benches/bench.rs
@@ -68,3 +68,26 @@ fn optimized_memchr2(b: &mut test::Bencher) {
});
b.bytes = haystack.len() as u64;
}
+
+#[bench]
+fn iterator_memchr3(b: &mut test::Bencher) {
+ let haystack = be... | 2 | 188 | 99 |
4b10f07fe8c32b8c88578459c6b5a991e7e23698 | bluss | 2015-12-19T06:13:21 | Use memrchr definition from libc | diff --git a/Cargo.toml b/Cargo.toml
index 49f5797..df29804 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -14,7 +14,7 @@ license = "Unlicense/MIT"
name = "memchr"
[dependencies]
-libc = "0.2"
+libc = "0.2.4"
[dev-dependencies]
quickcheck = "0.2"
diff --git a/src/lib.rs b/src/lib.rs
index 2475bcb..342e55e 100644
-... | 2 | 2 | 11 |
9e5e62c01b4cb49bf83788deddcb0939033f46c5 | Andrew Gallant | 2015-11-05T23:07:59 | Fallback memchr's might not be used. | diff --git a/src/lib.rs b/src/lib.rs
index 2ec7106..2475bcb 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -78,7 +78,7 @@ pub fn memchr(needle: u8, haystack: &[u8]) -> Option<usize> {
/// assert_eq!(memrchr(b'o', haystack), Some(17));
/// ```
pub fn memrchr(needle: u8, haystack: &[u8]) -> Option<usize> {
-
+
#... | 1 | 2 | 1 |
4b952004a6764d6b5d32310dec604d32feaecd67 | Andrew Gallant | 2015-11-05T23:07:46 | Bump to libc 0.2 | diff --git a/Cargo.toml b/Cargo.toml
index 78ac9ee..f1fe1b9 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -14,7 +14,7 @@ license = "Unlicense/MIT"
name = "memchr"
[dependencies]
-libc = "0.1"
+libc = "0.2"
[dev-dependencies]
quickcheck = "0.2" | 1 | 1 | 1 |
90e00ea379f7c26387ffbab7bbc2a92a8e0be4d6 | Andrew Gallant | 2015-08-30T15:29:07 | remove unnecessary * | diff --git a/Cargo.toml b/Cargo.toml
index b1adf47..8784fe3 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -14,7 +14,7 @@ license = "Unlicense/MIT"
name = "memchr"
[dependencies]
-libc = "0.1.*"
+libc = "0.1"
[dev-dependencies]
-quickcheck = "0.2.*"
+quickcheck = "0.2" | 1 | 2 | 2 |
6c40892972e6d4cf590c3a33d9ba5d1e67b4be95 | bluss | 2015-08-22T17:54:43 | Cargo.toml: Add bluss to authors | diff --git a/Cargo.toml b/Cargo.toml
index 03d64be..b1adf47 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,7 +1,7 @@
[package]
name = "memchr"
version = "0.1.5" #:version
-authors = ["Andrew Gallant <jamslam@gmail.com>"]
+authors = ["Andrew Gallant <jamslam@gmail.com>", "bluss"]
description = "Safe interface to me... | 1 | 1 | 1 |
d24cbc3cb82913568ad8fb1ee1dcb0779c311822 | bluss | 2015-08-22T17:53:51 | Add manually implemented fallback for memchr
Manually implemented memchr reads data in two usize at a time, and
performs better than libc memchr on some platforms.
Use the fallback by default on windows. | diff --git a/src/lib.rs b/src/lib.rs
index 1bee0d8..2ec7106 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -4,10 +4,10 @@ to the corresponding functions in `libc`.
*/
#![deny(missing_docs)]
+#![allow(unused_imports)]
extern crate libc;
-use libc::funcs::c95::string;
use libc::c_void;
use libc::{c_int, size_t};
... | 1 | 79 | 13 |
44b17b8f7d7c323a4cfbc3808bd7b34daa2a1084 | bluss | 2015-08-22T17:21:54 | Use iterator code in memrchr fallback's init and tail | diff --git a/src/lib.rs b/src/lib.rs
index 74ab6d6..1bee0d8 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -152,23 +152,19 @@ mod fallback {
let ptr = text.as_ptr();
// search to an aligned boundary
- let endptr = unsafe { ptr.offset(text.len() as isize) };
- let align = (endptr as usize)... | 1 | 9 | 18 |
92e43f295c5b1d84cfd832b510e085d7988697ed | bluss | 2015-08-20T00:19:31 | Add another quickcheck test for memchr
And use a random small offset from the start of the string to test all
pointer alignments. | diff --git a/src/lib.rs b/src/lib.rs
index 0bf8070..74ab6d6 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -297,16 +297,44 @@ mod tests {
}
#[test]
- fn qc_correct_reversed() {
- fn prop(a: Vec<u8>) -> bool {
+ fn qc_correct_memchr() {
+ fn prop(v: Vec<u8>, offset: u8) -> bool {
+ ... | 1 | 32 | 4 |
6a1b5d7d2cd1a9d36ad4aeb4c6aa9df3099a59a9 | bluss | 2015-08-19T21:14:41 | Better codegen for memrchr fallback
This rewriting to explicitly compute contains_zero_byte before the if,
allows the compiler to generate better code. | diff --git a/src/lib.rs b/src/lib.rs
index 9fb0b99..0bf8070 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -172,13 +172,13 @@ mod fallback {
while offset >= 2 * USIZE_BYTES {
unsafe {
- let mut u = *(ptr.offset(offset as isize - 2 * USIZE_BYTES as isize) as *const usize);
- ... | 1 | 5 | 5 |
9741001ae59a1dd9e7aaebb06a106890072983f6 | bluss | 2015-08-19T20:56:02 | Provide a faster fallback for memrchr on non-linux platforms
This implementation reads two usizes at a time and uses a "famous"
bithack to quickly check a whole word for containing a zero byte. By
using a word with our sought byte repeated and xor, we can convert
arbitrary byte search to a zero search. | diff --git a/src/lib.rs b/src/lib.rs
index 028038d..9fb0b99 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -8,8 +8,8 @@ to the corresponding functions in `libc`.
extern crate libc;
use libc::funcs::c95::string;
-use libc::types::common::c95::c_void;
-use libc::types::os::arch::c95::{c_int, size_t};
+use libc::c_void;
... | 1 | 128 | 5 |
f5a2ef28c5efb5a2449647fb45d26d2403956a5d | bluss | 2015-08-19T20:55:57 | benchmarks: Count bytes processed per iteration | diff --git a/benches/bench.rs b/benches/bench.rs
index 306356a..9db0fa6 100644
--- a/benches/bench.rs
+++ b/benches/bench.rs
@@ -14,6 +14,7 @@ fn iterator(b: &mut test::Bencher) {
b.iter(|| {
assert!(haystack.iter().position(|&b| b == needle).is_none());
});
+ b.bytes = haystack.len() as u64;
}
... | 1 | 4 | 0 |
8dac688d35f223d0dcf7a148cdb4476f444c7af1 | Andrew Gallant | 2015-08-15T16:03:20 | fix typo | diff --git a/benches/bench.rs b/benches/bench.rs
index d5707b4..306356a 100644
--- a/benches/bench.rs
+++ b/benches/bench.rs
@@ -39,6 +39,6 @@ fn libc_memrchr(b: &mut test::Bencher) {
let haystack = bench_data();
let needle = b'a';
b.iter(|| {
- assert!(memchr::memchr(needle, &haystack).is_none())... | 1 | 1 | 1 |
7c2c2aa30f88fb6ab58bdcea9d5cd9ab0a9416bb | Nicolas Koch | 2015-08-02T11:41:01 | Only compile optimized version of memrchr on linux.
Since memrchr() is not part os POSIX, some os's do not provide it. For
now, the optimized version is only compiled on linux. If other supported
targets are found to provide memrchr(), they can be added to the list as
well. | diff --git a/src/lib.rs b/src/lib.rs
index 7bd96f5..028038d 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -60,21 +60,33 @@ pub fn memchr(needle: u8, haystack: &[u8]) -> Option<usize> {
/// assert_eq!(memrchr(b'o', haystack), Some(17));
/// ```
pub fn memrchr(needle: u8, haystack: &[u8]) -> Option<usize> {
- // GNU'... | 1 | 24 | 12 |
45c1a87bf8ae36c42691586a77eb1f08f6cfa613 | Nicolas Koch | 2015-08-01T02:30:41 | Implement safe interface to memrchr.
This commit introduces the new function memrchr(), which is the reversed
counterpart to memchr(), and it's corresponding testcases and benchmarks. | diff --git a/benches/bench.rs b/benches/bench.rs
index cd93ae4..d5707b4 100644
--- a/benches/bench.rs
+++ b/benches/bench.rs
@@ -24,3 +24,21 @@ fn libc_memchr(b: &mut test::Bencher) {
assert!(memchr::memchr(needle, &haystack).is_none());
});
}
+
+#[bench]
+fn iterator_reversed(b: &mut test::Bencher) {
+ ... | 2 | 103 | 3 |
3f6bf8d4aff5564261c946951e7c865e79956f84 | Andrew Gallant | 2015-06-14T20:15:07 | Use `usize` instead of `isize`.
`memchr` should gurantee that a non-null pointer returned is strictly
greater than or equal to the start pointer, so this should never overflow. | diff --git a/src/lib.rs b/src/lib.rs
index 71aa015..2668c2a 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -40,7 +40,7 @@ pub fn memchr(needle: u8, haystack: &[u8]) -> Option<usize> {
if p.is_null() {
None
} else {
- Some((p as isize - (haystack.as_ptr() as isize)) as usize)
+ Some(p as us... | 1 | 1 | 1 |
0642661fded94c4095191627d554018a88f1b6fd | Roland Fredenhagen | 2025-12-19T22:53:27 | document-macro | diff --git a/src/trait_.rs b/src/trait_.rs
index 5c3fe6e..5ef00a6 100644
--- a/src/trait_.rs
+++ b/src/trait_.rs
@@ -71,6 +71,8 @@ pub enum Trait {
ZeroizeOnDrop,
}
+/// Call a function on the corresponding trait struct matching the trait enum
+/// variant.
macro_rules! trait_dispatch {
($self:expr, $method:ide... | 1 | 2 | 0 |
a6e35762e87acbf8acceecd711fee3da69f8daff | Roland Fredenhagen | 2025-12-19T23:00:20 | Disable repr_c_enums_larger_than_int in test | diff --git a/tests/discriminant.rs b/tests/discriminant.rs
index 673dfc0..c3ed536 100644
--- a/tests/discriminant.rs
+++ b/tests/discriminant.rs
@@ -1,4 +1,5 @@
-#![allow(clippy::enum_clike_unportable_variant)]
+#![allow(unknown_lints)] // make this not error on stable
+#![allow(clippy::enum_clike_unportable_variant, r... | 1 | 2 | 1 |
b4db3b444e713d8f2b0ac9acfb8a1df8adbe3dac | Roland Fredenhagen | 2025-11-18T16:39:12 | generate code using fqt for bool | diff --git a/src/item.rs b/src/item.rs
index e94f82f..304e8da 100644
--- a/src/item.rs
+++ b/src/item.rs
@@ -3,8 +3,8 @@
use proc_macro2::Ident;
#[cfg(not(feature = "nightly"))]
use {
- proc_macro2::{Span, TokenStream, TokenTree},
- quote::ToTokens,
+ proc_macro2::{Span, TokenStream},
+ quote::{quote, ToTokens},
s... | 11 | 130 | 111 |
04c70561836ad47f8ee6edf08edb09ad44e9a078 | Roland Fredenhagen | 2025-06-13T09:24:25 | taplo-fmt | diff --git a/Cargo.toml b/Cargo.toml
index ae1efc1..3335552 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -56,16 +56,16 @@ default.extend-words.wheres = "wheres"
[[package.metadata.release.pre-release-replacements]]
file = "CHANGELOG.md"
-search = '## \[Unreleased\]'
replace = """
<!-- ## [Unreleased] -->
## [{{ve... | 1 | 2 | 2 |
f8c0fcaa9bb3a117652b4294b228b8c5fd5147b9 | Roland Fredenhagen | 2025-06-08T10:52:48 | add cargo-release config | diff --git a/Cargo.toml b/Cargo.toml
index a7ad76b..bed2015 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -53,3 +53,19 @@ targets = []
[workspace.metadata.typos]
default.extend-words.wheres = "wheres"
+
+[[package.metadata.release.pre-release-replacements]]
+file = "CHANGELOG.md"
+search = '## \[Unreleased\]'
+replac... | 1 | 16 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.