]> git.lizzy.rs Git - rust.git/commitdiff
Remove one level of indirection for slice-based PartialEq impls
authorBjörn Steinbrink <bsteinbr@gmail.com>
Thu, 1 Oct 2015 16:17:49 +0000 (18:17 +0200)
committerBjörn Steinbrink <bsteinbr@gmail.com>
Thu, 1 Oct 2015 16:17:49 +0000 (18:17 +0200)
Using the comparison operators already refs the operands, so doing it
ourselves as well just adds an unnecessary level of indirection.

src/libcore/cmp_macros.rs

index 95dab3d165ad3f99cfa4db8034afa5cc492b0d7d..3863f63265b9383314a4d6d89163675f013084b5 100644 (file)
@@ -21,9 +21,9 @@ macro_rules! __impl_slice_eq1 {
         #[stable(feature = "rust1", since = "1.0.0")]
         impl<'a, 'b, A: $Bound, B> PartialEq<$Rhs> for $Lhs where A: PartialEq<B> {
             #[inline]
-            fn eq(&self, other: &$Rhs) -> bool { &self[..] == &other[..] }
+            fn eq(&self, other: &$Rhs) -> bool { self[..] == other[..] }
             #[inline]
-            fn ne(&self, other: &$Rhs) -> bool { &self[..] != &other[..] }
+            fn ne(&self, other: &$Rhs) -> bool { self[..] != other[..] }
         }
     }
 }
@@ -39,9 +39,9 @@ macro_rules! __impl_slice_eq2 {
         #[stable(feature = "rust1", since = "1.0.0")]
         impl<'a, 'b, A: $Bound, B> PartialEq<$Lhs> for $Rhs where B: PartialEq<A> {
             #[inline]
-            fn eq(&self, other: &$Lhs) -> bool { &self[..] == &other[..] }
+            fn eq(&self, other: &$Lhs) -> bool { self[..] == other[..] }
             #[inline]
-            fn ne(&self, other: &$Lhs) -> bool { &self[..] != &other[..] }
+            fn ne(&self, other: &$Lhs) -> bool { self[..] != other[..] }
         }
     }
 }