diff options
| author | Ralf Jung <post@ralfj.de> | 2023-08-14 09:53:53 +0200 |
|---|---|---|
| committer | Ralf Jung <post@ralfj.de> | 2023-08-14 09:53:53 +0200 |
| commit | 26cfd211fb00f7f9076bf12eb3eef4da341720d3 (patch) | |
| tree | 34e5f01cdf127615b119ba3027c2cbef739953f8 /library/core/src | |
| parent | 4cb4013464b3ec594e42dbed4d80110ee1817988 (diff) | |
| download | rust-26cfd211fb00f7f9076bf12eb3eef4da341720d3.tar.gz rust-26cfd211fb00f7f9076bf12eb3eef4da341720d3.zip | |
simplify is_nonoverlapping a bit
Diffstat (limited to 'library/core/src')
| -rw-r--r-- | library/core/src/intrinsics.rs | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/library/core/src/intrinsics.rs b/library/core/src/intrinsics.rs index 9ef2c7cde02..0442e1639ba 100644 --- a/library/core/src/intrinsics.rs +++ b/library/core/src/intrinsics.rs @@ -2568,7 +2568,7 @@ pub(crate) fn is_nonoverlapping<T>(src: *const T, dst: *const T, count: usize) - let size = mem::size_of::<T>() .checked_mul(count) .expect("is_nonoverlapping: `size_of::<T>() * count` overflows a usize"); - let diff = if src_usize > dst_usize { src_usize - dst_usize } else { dst_usize - src_usize }; + let diff = src_usize.abs_diff(dst_usize); // If the absolute distance between the ptrs is at least as big as the size of the buffer, // they do not overlap. diff >= size |
