commit | a38ff37d6f53c8225e381a9d3bb9f7814ac59f09 | [log] [tgz] |
---|---|---|
author | William Escande <wescande@google.com> | Tue Aug 23 05:41:15 2022 +0000 |
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | Tue Aug 23 05:41:15 2022 +0000 |
tree | e0d060a906ca13d4c0a098eeddb232a947b88388 | |
parent | 90976d2e23b03bbe54824e63e44eb407f75a2430 [diff] | |
parent | 18a1fae01afd9d766bb3034e8b7aa9f4b7da951d [diff] |
[Bluetooth apex] Use new apex name am: 0a5e74aeff am: 585117368f am: 872877cbcc am: 18a1fae01a Original change: https://android-review.googlesource.com/c/platform/external/rust/crates/memchr/+/2192258 Change-Id: I92ee372b02bb5cc499218f1b0d3be0415558ccdf Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This library provides heavily optimized routines for string search primitives.
Dual-licensed under MIT or the UNLICENSE.
memmem
sub-module provides forward and reverse substring search routines.In all such cases, routines operate on &[u8]
without regard to encoding. This is exactly what you want when searching either UTF-8 or arbitrary bytes.
memchr links to the standard library by default, but you can disable the std
feature if you want to use it in a #![no_std]
crate:
[dependencies] memchr = { version = "2", default-features = false }
On x86 platforms, when the std
feature is disabled, the SSE2 accelerated implementations will be used. When std
is enabled, AVX accelerated implementations will be used if the CPU is determined to support it at runtime.
memchr
is a routine that is part of libc, although this crate does not use libc by default. Instead, it uses its own routines, which are either vectorized or generic fallback routines. In general, these should be competitive with what‘s in libc, although this has not been tested for all architectures. If using memchr
from libc is desirable and a vectorized routine is not otherwise available in this crate, then enabling the libc
feature will use libc’s version of memchr
.
The rest of the functions in this crate, e.g., memchr2
or memrchr3
and the substring search routines, will always use the implementations in this crate. One exception to this is memrchr
, which is an extension in libc
found on Linux. On Linux, memrchr
is used in precisely the same scenario as memchr
, as described above.
This crate's minimum supported rustc
version is 1.41.1
.
The current policy is that the minimum Rust version required to use this crate can be increased in minor version updates. For example, if crate 1.0
requires Rust 1.20.0, then crate 1.0.z
for all values of z
will also require Rust 1.20.0 or newer. However, crate 1.y
for y > 0
may require a newer minimum version of Rust.
In general, this crate will be conservative with respect to the minimum supported version of Rust.
Given the complexity of the code in this crate, along with the pervasive use of unsafe
, this crate has an extensive testing strategy. It combines multiple approaches:
quickcheck
.cargo fuzz
.Improvements to the testing infrastructure are very welcome.
At time of writing, this crate's implementation of substring search actually has a few different algorithms to choose from depending on the situation.