Avoid unneeded inc/dec rec in RefPtr::operator=
This commit is contained in:
parent
95c1d25f28
commit
53184829ee
|
@ -24,11 +24,15 @@ struct RefPtr
|
||||||
|
|
||||||
RefPtr& operator=(const RefPtr& other)
|
RefPtr& operator=(const RefPtr& other)
|
||||||
{
|
{
|
||||||
release();
|
if (other.m_ptr != m_ptr)
|
||||||
m_ptr = other.m_ptr;
|
{
|
||||||
acquire();
|
release();
|
||||||
|
m_ptr = other.m_ptr;
|
||||||
|
acquire();
|
||||||
|
}
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
RefPtr& operator=(RefPtr&& other)
|
RefPtr& operator=(RefPtr&& other)
|
||||||
{
|
{
|
||||||
release();
|
release();
|
||||||
|
@ -40,9 +44,12 @@ struct RefPtr
|
||||||
|
|
||||||
RefPtr& operator=(T* ptr)
|
RefPtr& operator=(T* ptr)
|
||||||
{
|
{
|
||||||
release();
|
if (ptr != m_ptr)
|
||||||
m_ptr = ptr;
|
{
|
||||||
acquire();
|
release();
|
||||||
|
m_ptr = ptr;
|
||||||
|
acquire();
|
||||||
|
}
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user