mirror of
https://github.com/serde-rs/json.git
synced 2025-10-02 15:26:00 +00:00
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.
This commit is contained in:
parent
50c4328e21
commit
3d837e1cc4
15
src/read.rs
15
src/read.rs
@ -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
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user