Avoid unneccessary increment/decrement of reference count

[SVN r44711]
This commit is contained in:
Daniel Frey committed 2008-04-22 06:31:32 +00:00
1 parent b541145a60
commit e12ed6864b
1 file changed
+14 -6
+14 -6
View File
@@ -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 != 0) tmp->weak_add_ref();
if(pi_ != 0) pi_->weak_release(); if( tmp != pi_ )
pi_ = tmp; {
if(tmp != 0) tmp->weak_add_ref();
if(pi_ != 0) pi_->weak_release();
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 != 0) tmp->weak_add_ref();
if(pi_ != 0) pi_->weak_release(); if( tmp != pi_ )
pi_ = tmp; {
if(tmp != 0) tmp->weak_add_ref();
if(pi_ != 0) pi_->weak_release();
pi_ = tmp;
}
return *this; return *this;
} }