Optimized ResourceRef assignation
Former-commit-id: 9dfdadb8e34f17c93caabef12f097504c89ee51b
This commit is contained in:
parent
63fae2f9ca
commit
b82cbc074b
|
|
@ -32,6 +32,7 @@ class NzResourceRef
|
||||||
operator T*() const;
|
operator T*() const;
|
||||||
T* operator->() const;
|
T* operator->() const;
|
||||||
|
|
||||||
|
NzResourceRef& operator=(T* resource);
|
||||||
NzResourceRef& operator=(const NzResourceRef& ref);
|
NzResourceRef& operator=(const NzResourceRef& ref);
|
||||||
NzResourceRef& operator=(NzResourceRef&& ref);
|
NzResourceRef& operator=(NzResourceRef&& ref);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -93,6 +93,23 @@ T* NzResourceRef<T>::operator->() const
|
||||||
return m_resource;
|
return m_resource;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
NzResourceRef<T>& NzResourceRef<T>::operator=(T* resource)
|
||||||
|
{
|
||||||
|
if (m_resource != resource)
|
||||||
|
{
|
||||||
|
Release();
|
||||||
|
|
||||||
|
if (resource)
|
||||||
|
{
|
||||||
|
m_resource = resource;
|
||||||
|
m_resource->AddResourceReference();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
NzResourceRef<T>& NzResourceRef<T>::operator=(const NzResourceRef& ref)
|
NzResourceRef<T>& NzResourceRef<T>::operator=(const NzResourceRef& ref)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue