about summary refs log tree commit diff
path: root/src/liballoc/sync.rs
diff options
context:
space:
mode:
authorThomas Heck <t@b128.net>2019-05-11 10:23:07 +0200
committerThomas Heck <t@b128.net>2019-05-11 11:03:28 +0200
commit740a8dabb413abecd88a202f2370252b33e73a7f (patch)
treea0e08b8f22d7b27be2ad2a49927ec39b7d6f8209 /src/liballoc/sync.rs
parent7519eaca9a2565cd60e645b2dfda61f205bd25df (diff)
downloadrust-740a8dabb413abecd88a202f2370252b33e73a7f.tar.gz
rust-740a8dabb413abecd88a202f2370252b33e73a7f.zip
add comment to `Rc`/`Arc`'s `Eq` specialization
Diffstat (limited to 'src/liballoc/sync.rs')
-rw-r--r--src/liballoc/sync.rs5
1 files changed, 5 insertions, 0 deletions
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]