Skip to content

Commit 3d837e1

Browse files
committed
Ensure the SWAR chunks are 64-bit in more cases
Various architectures have support for 64-bit integers, but there are Rust targets for those architectures where the pointer size is intentionally just 32-bit. For SWAR this smaller pointer size would negatively affect those targets, so this PR ensures the chunk size stays 64-bit on those targets.
1 parent 50c4328 commit 3d837e1

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/read.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,22 @@ impl<'a> SliceRead<'a> {
445445
// than a naive loop. It runs faster than equivalent two-pass memchr2+SWAR code on
446446
// benchmarks and it's cross-platform, so probably the right fit.
447447
// [1]: https://groups.google.com/forum/#!original/comp.lang.c/2HtQXvg7iKc/xOJeipH6KLMJ
448+
449+
// The following architectures have native support for 64-bit integers,
450+
// but have targets where usize is not 64-bit.
451+
#[cfg(any(
452+
target_arch = "aarch64",
453+
target_arch = "x86_64",
454+
target_arch = "wasm32",
455+
))]
456+
type Chunk = u64;
457+
#[cfg(not(any(
458+
target_arch = "aarch64",
459+
target_arch = "x86_64",
460+
target_arch = "wasm32",
461+
)))]
448462
type Chunk = usize;
463+
449464
const STEP: usize = mem::size_of::<Chunk>();
450465
const ONE_BYTES: Chunk = Chunk::MAX / 255; // 0x0101...01
451466

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy