Skip to content

Commit

Permalink
Merge branch 'main' into big-int-as-float
Browse files Browse the repository at this point in the history
  • Loading branch information
richarddd authored Jan 10, 2024
2 parents e1a6a8a + 7a2d44f commit c79bc90
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "simd-json"
version = "0.13.4"
version = "0.13.6"
authors = ["Heinz N. Gies <[email protected]>", "Sunny Gleason"]
edition = "2021"
exclude = ["data/*", "fuzz/*"]
Expand Down
9 changes: 8 additions & 1 deletion src/impls/native/stage1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,13 @@ impl Stage1Parse for SimdInput {
base.reserve(64);
let final_len = l + cnt;

let is_unaligned = l % 4 != 0;
let write_fn = if is_unaligned {
std::ptr::write_unaligned
} else {
std::ptr::write
};

while bits != 0 {
let v0 = bits.trailing_zeros() as i32;
bits &= bits.wrapping_sub(1);
Expand All @@ -461,7 +468,7 @@ impl Stage1Parse for SimdInput {
idx_64_v[2] + v2,
idx_64_v[3] + v3,
];
std::ptr::write(base.as_mut_ptr().add(l).cast::<[i32; 4]>(), v);
write_fn(base.as_mut_ptr().add(l).cast::<[i32; 4]>(), v);
l += 4;
}
// We have written all the data
Expand Down
9 changes: 8 additions & 1 deletion src/impls/neon/stage1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,13 @@ impl Stage1Parse for SimdInput {
base.reserve(64);
let final_len = l + cnt;

let is_unaligned = l % 4 != 0;
let write_fn = if is_unaligned {
std::ptr::write_unaligned
} else {
std::ptr::write
};

while bits != 0 {
let v0 = bits.trailing_zeros() as i32;
bits &= bits.wrapping_sub(1);
Expand All @@ -202,7 +209,7 @@ impl Stage1Parse for SimdInput {

let v: int32x4_t = mem::transmute([v0, v1, v2, v3]);
let v: int32x4_t = vaddq_s32(idx_64_v, v);
std::ptr::write(base.as_mut_ptr().add(l).cast::<int32x4_t>(), v);
write_fn(base.as_mut_ptr().add(l).cast::<int32x4_t>(), v);
l += 4;
}
// We have written all the data
Expand Down

0 comments on commit c79bc90

Please sign in to comment.