Skip to content

Commit 495fa48

Browse files
committed
use pointer::add in memchr impl
1 parent a2cdbf8 commit 495fa48

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

library/core/src/slice/memchr.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,8 @@ pub fn memrchr(x: u8, text: &[u8]) -> Option<usize> {
124124
// SAFETY: offset starts at len - suffix.len(), as long as it is greater than
125125
// min_aligned_offset (prefix.len()) the remaining distance is at least 2 * chunk_bytes.
126126
unsafe {
127-
let u = *(ptr.offset(offset as isize - 2 * chunk_bytes as isize) as *const Chunk);
128-
let v = *(ptr.offset(offset as isize - chunk_bytes as isize) as *const Chunk);
127+
let u = *(ptr.add(offset - 2 * chunk_bytes) as *const Chunk);
128+
let v = *(ptr.add(offset - chunk_bytes) as *const Chunk);
129129

130130
// Break if there is a matching byte.
131131
let zu = contains_zero_byte(u ^ repeated_x);

0 commit comments

Comments
 (0)