Skip to content

Commit 8d3b306

Browse files
committed
avoid a negation in is_nonoverlapping
1 parent d1d0de9 commit 8d3b306

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/libcore/intrinsics.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -1429,8 +1429,9 @@ pub(crate) fn is_nonoverlapping<T>(src: *const T, dst: *const T, count: usize) -
14291429
let dst_usize = dst as usize;
14301430
let size = mem::size_of::<T>().checked_mul(count).unwrap();
14311431
let diff = if src_usize > dst_usize { src_usize - dst_usize } else { dst_usize - src_usize };
1432-
let overlaps = size > diff;
1433-
!overlaps
1432+
// If the absolute distance between the ptrs is at least as big as the size of the buffer,
1433+
// they do not overlap.
1434+
diff >= size
14341435
}
14351436

14361437
/// Copies `count * size_of::<T>()` bytes from `src` to `dst`. The source

0 commit comments

Comments
 (0)