about summary refs log tree commit diff
path: root/src/liballoc
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2019-05-11 22:13:10 +0000
committerbors <bors@rust-lang.org>2019-05-11 22:13:10 +0000
commitd28e948b92d85b5b93f48075d010f799cf9642b6 (patch)
treeebd4206ec6ca498170c3511da2707bf0c09f66d4 /src/liballoc
parentaf98304b9a006e2f9a367b1f79dd7655f243c150 (diff)
parentf2dd97cc34bf8d28f1a6cb7f4b7f6dbcd7e3e824 (diff)
downloadrust-d28e948b92d85b5b93f48075d010f799cf9642b6.tar.gz
rust-d28e948b92d85b5b93f48075d010f799cf9642b6.zip
Auto merge of #60748 - Centril:rollup-rr63jqo, r=Centril
Rollup of 4 pull requests

Successful merges:

 - #60720 (Remove unnecessary unwraps)
 - #60727 (add comment to `Rc`/`Arc`'s `Eq` specialization)
 - #60733 (Cleanup the .await HIR lowering with .stmt(..).)
 - #60741 (Remove redundant "let mut" in write_graph_label)

Failed merges:

r? @ghost
Diffstat (limited to 'src/liballoc')
-rw-r--r--src/liballoc/rc.rs5
-rw-r--r--src/liballoc/sync.rs5
2 files changed, 10 insertions, 0 deletions
diff --git a/src/liballoc/rc.rs b/src/liballoc/rc.rs
index 68eecd97ea1..0dffb19476f 100644
--- a/src/liballoc/rc.rs
+++ b/src/liballoc/rc.rs
@@ -932,6 +932,11 @@ impl<T: ?Sized + PartialEq> RcEqIdent<T> for Rc<T> {
     }
 }
 
+/// We're doing this specialization here, and not as a more general optimization on `&T`, because it
+/// would otherwise add a cost to all equality checks on refs. We assume that `Rc`s are used to
+/// store large values, that are slow to clone, but also heavy to check for equality, causing this
+/// cost to pay off more easily. It's also more likely to have two `Rc` clones, that point to
+/// the same value, than two `&T`s.
 #[stable(feature = "rust1", since = "1.0.0")]
 impl<T: ?Sized + Eq> RcEqIdent<T> for Rc<T> {
     #[inline]
diff --git a/src/liballoc/sync.rs b/src/liballoc/sync.rs
index 466e806663c..90c7859b3db 100644
--- a/src/liballoc/sync.rs
+++ b/src/liballoc/sync.rs
@@ -1377,6 +1377,11 @@ impl<T: ?Sized + PartialEq> ArcEqIdent<T> for Arc<T> {
     }
 }
 
+/// We're doing this specialization here, and not as a more general optimization on `&T`, because it
+/// would otherwise add a cost to all equality checks on refs. We assume that `Arc`s are used to
+/// store large values, that are slow to clone, but also heavy to check for equality, causing this
+/// cost to pay off more easily. It's also more likely to have two `Arc` clones, that point to
+/// the same value, than two `&T`s.
 #[stable(feature = "rust1", since = "1.0.0")]
 impl<T: ?Sized + Eq> ArcEqIdent<T> for Arc<T> {
     #[inline]