Self-assignment optimization

[SVN r22233]
This commit is contained in:
Peter Dimov
2004-02-10 23:17:12 +00:00
parent 7fb399b3bb
commit 53cc52127b

View File

@ -395,9 +395,13 @@ public:
shared_count & operator= (shared_count const & r) // nothrow
{
sp_counted_base * tmp = r.pi_;
if(tmp != 0) tmp->add_ref_copy();
if(pi_ != 0) pi_->release();
pi_ = tmp;
if(tmp != pi_)
{
if(tmp != 0) tmp->add_ref_copy();
if(pi_ != 0) pi_->release();
pi_ = tmp;
}
return *this;
}