Skip to content

Commit

Permalink
Big endian support
Browse files Browse the repository at this point in the history
  • Loading branch information
purplesyringa committed Aug 11, 2024
1 parent 5496579 commit a95d6df
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -453,9 +453,14 @@ impl<'a> SliceRead<'a> {
let contains_backslash = chars_backslash.wrapping_sub(ONE_BYTES) & !chars_backslash;
let masked = (contains_ctrl | contains_quote | contains_backslash) & (ONE_BYTES << 7);
if masked != 0 {
let addresswise_first_bit = if cfg!(target_endian = "little") {
masked.trailing_zeros()
} else {
masked.leading_zeros()
};
// SAFETY: chunk is in-bounds for slice
self.index = unsafe { chunk.as_ptr().offset_from(self.slice.as_ptr()) } as usize
+ masked.trailing_zeros() as usize / 8;
+ addresswise_first_bit as usize / 8;
return;
}
}
Expand Down

0 comments on commit a95d6df

Please sign in to comment.