about summary refs log tree commit diff
diff options
context:
space:
mode:
authorOliver Scherer <github35764891676564198441@oli-obk.de>2020-06-20 14:58:15 +0200
committerOliver Scherer <github35764891676564198441@oli-obk.de>2020-06-20 14:58:15 +0200
commit98e97a46e2201520f54082abe462728b0a770a6b (patch)
tree740ef8e6f59e39c422e0415435eacddca9cd1298
parent53686b91caac6c6782b8d2a41675f4f0941aa254 (diff)
Address review comments
-rw-r--r--src/libcore/ptr/const_ptr.rs4
-rw-r--r--src/libcore/ptr/mut_ptr.rs4
-rw-r--r--src/libcore/slice/mod.rs47
3 files changed, 13 insertions, 42 deletions
diff --git a/src/libcore/ptr/const_ptr.rs b/src/libcore/ptr/const_ptr.rs
index 0e2e6848416..e5ac81d8789 100644
--- a/src/libcore/ptr/const_ptr.rs
+++ b/src/libcore/ptr/const_ptr.rs
@@ -295,7 +295,7 @@ impl<T: ?Sized> *const T {
         intrinsics::ptr_offset_from(self, origin)
     }
 
-    /// Returns whether two pointers are guaranteed equal.
+    /// Returns whether two pointers are guaranteed to be equal.
     ///
     /// At runtime this function behaves like `self == other`.
     /// However, in some contexts (e.g., compile-time evaluation),
@@ -328,7 +328,7 @@ impl<T: ?Sized> *const T {
         intrinsics::ptr_guaranteed_eq(self, other)
     }
 
-    /// Returns whether two pointers are guaranteed not equal.
+    /// Returns whether two pointers are guaranteed to be inequal.
     ///
     /// At runtime this function behaves like `self != other`.
     /// However, in some contexts (e.g., compile-time evaluation),
diff --git a/src/libcore/ptr/mut_ptr.rs b/src/libcore/ptr/mut_ptr.rs
index 67ace1f72a0..b8ff5b0dc72 100644
--- a/src/libcore/ptr/mut_ptr.rs
+++ b/src/libcore/ptr/mut_ptr.rs
@@ -273,7 +273,7 @@ impl<T: ?Sized> *mut T {
         if self.is_null() { None } else { Some(&mut *self) }
     }
 
-    /// Returns whether two pointers are guaranteed equal.
+    /// Returns whether two pointers are guaranteed to be equal.
     ///
     /// At runtime this function behaves like `self == other`.
     /// However, in some contexts (e.g., compile-time evaluation),
@@ -306,7 +306,7 @@ impl<T: ?Sized> *mut T {
         intrinsics::ptr_guaranteed_eq(self as *const _, other as *const _)
     }
 
-    /// Returns whether two pointers are guaranteed not equal.
+    /// Returns whether two pointers are guaranteed to be inequal.
     ///
     /// At runtime this function behaves like `self != other`.
     /// However, in some contexts (e.g., compile-time evaluation),
diff --git a/src/libcore/slice/mod.rs b/src/libcore/slice/mod.rs
index 12932b06d32..c69aafe687c 100644
--- a/src/libcore/slice/mod.rs
+++ b/src/libcore/slice/mod.rs
@@ -5946,8 +5946,7 @@ where
     }
 }
 
-// Remove after boostrap bump
-#[cfg(bootstrap)]
+// Use an equal-pointer optimization when types are `Eq`
 impl<A> SlicePartialEq<A> for [A]
 where
     A: PartialEq<A> + Eq,
@@ -5957,47 +5956,14 @@ where
             return false;
         }
 
+        #[cfg(bootstrap)]
         if self.as_ptr() == other.as_ptr() {
             return true;
         }
 
-        self.iter().zip(other.iter()).all(|(x, y)| x == y)
-    }
-}
-
-// Remove after boostrap bump
-#[cfg(bootstrap)]
-impl<A> SlicePartialEq<A> for [A]
-where
-    A: PartialEq<A> + BytewiseEquality,
-{
-    fn equal(&self, other: &[A]) -> bool {
-        if self.len() != other.len() {
-            return false;
-        }
-        if self.as_ptr() == other.as_ptr() {
-            return true;
-        }
-        unsafe {
-            let size = mem::size_of_val(self);
-            memcmp(self.as_ptr() as *const u8, other.as_ptr() as *const u8, size) == 0
-        }
-    }
-}
-
-// Use an equal-pointer optimization when types are `Eq`
-#[cfg(not(bootstrap))]
-impl<A> SlicePartialEq<A> for [A]
-where
-    A: PartialEq<A> + Eq,
-{
-    default fn equal(&self, other: &[A]) -> bool {
-        if self.len() != other.len() {
-            return false;
-        }
-
         // While performance would suffer if `guaranteed_eq` just returned `false`
         // for all arguments, correctness and return value of this function are not affected.
+        #[cfg(not(bootstrap))]
         if self.as_ptr().guaranteed_eq(other.as_ptr()) {
             return true;
         }
@@ -6007,7 +5973,6 @@ where
 }
 
 // Use memcmp for bytewise equality when the types allow
-#[cfg(not(bootstrap))]
 impl<A> SlicePartialEq<A> for [A]
 where
     A: PartialEq<A> + BytewiseEquality,
@@ -6017,8 +5982,14 @@ where
             return false;
         }
 
+        #[cfg(bootstrap)]
+        if self.as_ptr() == other.as_ptr() {
+            return true;
+        }
+
         // While performance would suffer if `guaranteed_eq` just returned `false`
         // for all arguments, correctness and return value of this function are not affected.
+        #[cfg(not(bootstrap))]
         if self.as_ptr().guaranteed_eq(other.as_ptr()) {
             return true;
         }