Avoid unneeded inc/dec rec in RefPtr::operator=
This commit is contained in:
parent
95c1d25f28
commit
53184829ee
|
@ -23,12 +23,16 @@ struct RefPtr
|
|||
: m_ptr(other.m_ptr) { other.m_ptr = nullptr; moved(&other); }
|
||||
|
||||
RefPtr& operator=(const RefPtr& other)
|
||||
{
|
||||
if (other.m_ptr != m_ptr)
|
||||
{
|
||||
release();
|
||||
m_ptr = other.m_ptr;
|
||||
acquire();
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
RefPtr& operator=(RefPtr&& other)
|
||||
{
|
||||
release();
|
||||
|
@ -39,10 +43,13 @@ struct RefPtr
|
|||
}
|
||||
|
||||
RefPtr& operator=(T* ptr)
|
||||
{
|
||||
if (ptr != m_ptr)
|
||||
{
|
||||
release();
|
||||
m_ptr = ptr;
|
||||
acquire();
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user