diff options
| author | Ben Kimock <kimockb@gmail.com> | 2025-08-04 13:10:09 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-08-04 13:10:09 +0000 |
| commit | ee1b237215ee90df2c0102457fa2d0e9c2df8753 (patch) | |
| tree | d7b99f917db35f8a07550c15b2544e0563612b5e /library/std/src/sys | |
| parent | ee00b998177899c10bea83a38c46627f27496ba2 (diff) | |
| parent | ab7c35995d9489821cc8b70ac1da069090ee56c9 (diff) | |
| download | rust-ee1b237215ee90df2c0102457fa2d0e9c2df8753.tar.gz rust-ee1b237215ee90df2c0102457fa2d0e9c2df8753.zip | |
Merge pull request #4513 from rust-lang/rustup-2025-08-04
Automatic Rustup
Diffstat (limited to 'library/std/src/sys')
| -rw-r--r-- | library/std/src/sys/pal/uefi/helpers.rs | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/library/std/src/sys/pal/uefi/helpers.rs b/library/std/src/sys/pal/uefi/helpers.rs index 271dc4d11de..b50574de937 100644 --- a/library/std/src/sys/pal/uefi/helpers.rs +++ b/library/std/src/sys/pal/uefi/helpers.rs @@ -444,17 +444,17 @@ impl<'a> DevicePathNode<'a> { impl<'a> PartialEq for DevicePathNode<'a> { fn eq(&self, other: &Self) -> bool { - let self_len = self.length(); - let other_len = other.length(); - - self_len == other_len - && unsafe { - compiler_builtins::mem::memcmp( - self.protocol.as_ptr().cast(), - other.protocol.as_ptr().cast(), - usize::from(self_len), - ) == 0 - } + // Compare as a single buffer rather than by field since it optimizes better. + // + // SAFETY: `Protocol` is followed by a buffer of `length - sizeof::<Protocol>()`. `Protocol` + // has no padding so it is sound to interpret as a slice. + unsafe { + let s1 = + slice::from_raw_parts(self.protocol.as_ptr().cast::<u8>(), self.length().into()); + let s2 = + slice::from_raw_parts(other.protocol.as_ptr().cast::<u8>(), other.length().into()); + s1 == s2 + } } } |
