gecko-dev/third_party/rust/memchr
Nathan Froyd b93bf873ba Bug 1502964 - part 2 - update winapi to froydnj/winapi-rs#aarch64; r=ted.mielczarek 2018-11-02 10:56:08 -04:00
..
benches
src Bug 1463251 - Part 2. Revendor dependencies. r=ato,jgraham 2018-05-21 22:34:18 +02:00
.cargo-checksum.json Bug 1502964 - part 2 - update winapi to froydnj/winapi-rs#aarch64; r=ted.mielczarek 2018-11-02 10:56:08 -04:00
COPYING
Cargo.toml Bug 1463251 - Part 2. Revendor dependencies. r=ato,jgraham 2018-05-21 22:34:18 +02:00
LICENSE-MIT
Makefile
README.md
UNLICENSE
appveyor.yml
ctags.rust
session.vim

README.md

This crate provides a safe interface libc's memchr and memrchr. This crate also provides fallback implementations when either function is unavailable.

Build status Build status

Dual-licensed under MIT or the UNLICENSE.

Documentation

https://docs.rs/memchr

no_std

memchr links to the standard library by default, but you can disable the use_std feature if you want to use it in a #![no_std] crate:

[dependencies]
memchr = { version = "1.0", default-features = false }

Performance

On my system (Linux/amd64), memchr is about an order of magnitude faster than the more idiomatic haystack.iter().position(|&b| b == needle):

test iterator          ... bench:       5,280 ns/iter (+/- 13) = 1893 MB/s
test iterator_reversed ... bench:       5,271 ns/iter (+/- 7) = 1897 MB/s
test libc_memchr       ... bench:         202 ns/iter (+/- 0) = 49504 MB/s
test libc_memrchr      ... bench:         197 ns/iter (+/- 1) = 50761 MB/s