diff options
| author | Maybe Waffle <waffle.lapkin@gmail.com> | 2022-08-21 02:16:51 +0400 |
|---|---|---|
| committer | Maybe Waffle <waffle.lapkin@gmail.com> | 2022-09-04 17:27:35 +0400 |
| commit | 495fa48790fad465edcdb7965d349617854a86c3 (patch) | |
| tree | 71865b561fbd62a8dca73722bc7ebacd2b5737ea | |
| parent | a2cdbf89637cd38fa5f1badbbc26b049a14345dd (diff) | |
| download | rust-495fa48790fad465edcdb7965d349617854a86c3.tar.gz rust-495fa48790fad465edcdb7965d349617854a86c3.zip | |
use `pointer::add` in memchr impl
| -rw-r--r-- | library/core/src/slice/memchr.rs | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/library/core/src/slice/memchr.rs b/library/core/src/slice/memchr.rs index dffeaf6a834..d8a4fd6c1ce 100644 --- a/library/core/src/slice/memchr.rs +++ b/library/core/src/slice/memchr.rs @@ -124,8 +124,8 @@ pub fn memrchr(x: u8, text: &[u8]) -> Option<usize> { // SAFETY: offset starts at len - suffix.len(), as long as it is greater than // min_aligned_offset (prefix.len()) the remaining distance is at least 2 * chunk_bytes. unsafe { - let u = *(ptr.offset(offset as isize - 2 * chunk_bytes as isize) as *const Chunk); - let v = *(ptr.offset(offset as isize - chunk_bytes as isize) as *const Chunk); + let u = *(ptr.add(offset - 2 * chunk_bytes) as *const Chunk); + let v = *(ptr.add(offset - chunk_bytes) as *const Chunk); // Break if there is a matching byte. let zu = contains_zero_byte(u ^ repeated_x); |
