Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure the SWAR chunks are 64-bit in more cases #1182

Merged
merged 1 commit into from
Aug 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,22 @@ impl<'a> SliceRead<'a> {
// than a naive loop. It runs faster than equivalent two-pass memchr2+SWAR code on
// benchmarks and it's cross-platform, so probably the right fit.
// [1]: https://groups.google.com/forum/#!original/comp.lang.c/2HtQXvg7iKc/xOJeipH6KLMJ

// The following architectures have native support for 64-bit integers,
// but have targets where usize is not 64-bit.
#[cfg(any(
target_arch = "aarch64",
target_arch = "x86_64",
target_arch = "wasm32",
))]
type Chunk = u64;
#[cfg(not(any(
target_arch = "aarch64",
target_arch = "x86_64",
target_arch = "wasm32",
)))]
type Chunk = usize;

const STEP: usize = mem::size_of::<Chunk>();
const ONE_BYTES: Chunk = Chunk::MAX / 255; // 0x0101...01

Expand Down