diff options
author | 2024-02-06 13:41:44 -0500 | |
---|---|---|
committer | 2024-02-06 10:41:44 -0800 | |
commit | 47e83056f28e15e4ca68056a0136f3920b753783 (patch) | |
tree | 107f9d087ca1e485bc9b81fd33e452b49de60f24 | |
parent | 8bcac21cb44c112f20e8dd31475033ff448e35ce (diff) | |
download | bytes-47e83056f28e15e4ca68056a0136f3920b753783.tar.gz bytes-47e83056f28e15e4ca68056a0136f3920b753783.tar.zst bytes-47e83056f28e15e4ca68056a0136f3920b753783.zip |
Use sub instead of offset (#668)
We're always subtracting here, and we already have a usize, so `sub`
seems like a more appropriate usage to me.
Diffstat (limited to '')
-rw-r--r-- | src/bytes_mut.rs | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/bytes_mut.rs b/src/bytes_mut.rs index 5566f2d..d1c1411 100644 --- a/src/bytes_mut.rs +++ b/src/bytes_mut.rs @@ -617,7 +617,7 @@ impl BytesMut { // // Just move the pointer back to the start after copying // data back. - let base_ptr = self.ptr.as_ptr().offset(-(off as isize)); + let base_ptr = self.ptr.as_ptr().sub(off); // Since `off >= self.len()`, the two regions don't overlap. ptr::copy_nonoverlapping(self.ptr.as_ptr(), base_ptr, self.len); self.ptr = vptr(base_ptr); @@ -1697,7 +1697,7 @@ fn offset_from(dst: *mut u8, original: *mut u8) -> usize { } unsafe fn rebuild_vec(ptr: *mut u8, mut len: usize, mut cap: usize, off: usize) -> Vec<u8> { - let ptr = ptr.offset(-(off as isize)); + let ptr = ptr.sub(off); len += off; cap += off; |