forked from boostorg/smart_ptr
Avoid unneccessary increment/decrement of reference count
[SVN r44711]
This commit is contained in:
@@ -324,9 +324,13 @@ public:
|
|||||||
weak_count & operator= (shared_count const & r) // nothrow
|
weak_count & operator= (shared_count const & r) // nothrow
|
||||||
{
|
{
|
||||||
sp_counted_base * tmp = r.pi_;
|
sp_counted_base * tmp = r.pi_;
|
||||||
|
|
||||||
|
if( tmp != pi_ )
|
||||||
|
{
|
||||||
if(tmp != 0) tmp->weak_add_ref();
|
if(tmp != 0) tmp->weak_add_ref();
|
||||||
if(pi_ != 0) pi_->weak_release();
|
if(pi_ != 0) pi_->weak_release();
|
||||||
pi_ = tmp;
|
pi_ = tmp;
|
||||||
|
}
|
||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
@@ -334,9 +338,13 @@ public:
|
|||||||
weak_count & operator= (weak_count const & r) // nothrow
|
weak_count & operator= (weak_count const & r) // nothrow
|
||||||
{
|
{
|
||||||
sp_counted_base * tmp = r.pi_;
|
sp_counted_base * tmp = r.pi_;
|
||||||
|
|
||||||
|
if( tmp != pi_ )
|
||||||
|
{
|
||||||
if(tmp != 0) tmp->weak_add_ref();
|
if(tmp != 0) tmp->weak_add_ref();
|
||||||
if(pi_ != 0) pi_->weak_release();
|
if(pi_ != 0) pi_->weak_release();
|
||||||
pi_ = tmp;
|
pi_ = tmp;
|
||||||
|
}
|
||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user