File tree Expand file tree Collapse file tree 2 files changed +10
-0
lines changed Expand file tree Collapse file tree 2 files changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -932,6 +932,11 @@ impl<T: ?Sized + PartialEq> RcEqIdent<T> for Rc<T> {
932
932
}
933
933
}
934
934
935
+ /// We're doing this specialization here, and not as a more general optimization on `&T`, because it
936
+ /// would otherwise add a cost to all equality checks on refs. We assume that `Rc`s are used to
937
+ /// store large values, that are slow to clone, but also heavy to check for equality, causing this
938
+ /// cost to pay off more easily. It's also more likely to have two `Rc` clones, that point to
939
+ /// the same value, than two `&T`s.
935
940
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
936
941
impl < T : ?Sized + Eq > RcEqIdent < T > for Rc < T > {
937
942
#[ inline]
Original file line number Diff line number Diff line change @@ -1377,6 +1377,11 @@ impl<T: ?Sized + PartialEq> ArcEqIdent<T> for Arc<T> {
1377
1377
}
1378
1378
}
1379
1379
1380
+ /// We're doing this specialization here, and not as a more general optimization on `&T`, because it
1381
+ /// would otherwise add a cost to all equality checks on refs. We assume that `Arc`s are used to
1382
+ /// store large values, that are slow to clone, but also heavy to check for equality, causing this
1383
+ /// cost to pay off more easily. It's also more likely to have two `Arc` clones, that point to
1384
+ /// the same value, than two `&T`s.
1380
1385
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
1381
1386
impl < T : ?Sized + Eq > ArcEqIdent < T > for Arc < T > {
1382
1387
#[ inline]
You can’t perform that action at this time.
0 commit comments