Skip to content

Commit fec0376

Browse files
authored
Merge pull request #1182 from CryZe/chunk-64bit
Ensure the SWAR chunks are 64-bit in more cases
2 parents 50c4328 + 3d837e1 commit fec0376

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/read.rs

+15
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)