@@ -909,6 +909,8 @@ trait RcBoxPtr<T> {
909
909
fn inc_strong ( & self ) {
910
910
let strong = self . strong ( ) ;
911
911
// The reference count is always at least one unless we're about to drop the type
912
+ // This allows the bulk of the destructor to be omitted in cases where we know that
913
+ // the reference count must be > 0.
912
914
unsafe { assume ( strong > 0 ) ; }
913
915
self . inner ( ) . strong . set ( strong + 1 ) ;
914
916
}
@@ -917,6 +919,8 @@ trait RcBoxPtr<T> {
917
919
fn dec_strong ( & self ) {
918
920
let strong = self . strong ( ) ;
919
921
// The reference count is always at least one unless we're about to drop the type
922
+ // This allows the bulk of the destructor to be omitted in cases where we know that
923
+ // the reference count must be > 0
920
924
unsafe { assume ( strong > 0 ) ; }
921
925
self . inner ( ) . strong . set ( strong - 1 ) ;
922
926
}
@@ -936,7 +940,9 @@ impl<T> RcBoxPtr<T> for Rc<T> {
936
940
fn inner ( & self ) -> & RcBox < T > {
937
941
unsafe {
938
942
// Safe to assume this here, as if it weren't true, we'd be breaking
939
- // the contract anyway
943
+ // the contract anyway.
944
+ // This allows the null check to be elided in the destructor if we
945
+ // manipulated the reference count in the same function.
940
946
assume ( !self . _ptr . is_null ( ) ) ;
941
947
& ( * * self . _ptr )
942
948
}
@@ -949,6 +955,8 @@ impl<T> RcBoxPtr<T> for Weak<T> {
949
955
unsafe {
950
956
// Safe to assume this here, as if it weren't true, we'd be breaking
951
957
// the contract anyway
958
+ // This allows the null check to be elided in the destructor if we
959
+ // manipulated the reference count in the same function.
952
960
assume ( !self . _ptr . is_null ( ) ) ;
953
961
& ( * * self . _ptr )
954
962
}
0 commit comments