summaryrefslogtreecommitdiffstats
path: root/Common/interface
diff options
context:
space:
mode:
authorEgor Yusov <egor.yusov@gmail.com>2019-04-11 16:15:58 +0000
committerEgor Yusov <egor.yusov@gmail.com>2019-04-11 16:15:58 +0000
commitf6f030dbdc1b8cd636f1e340e506ae776b57999c (patch)
tree01acd74a70738812860048bd026176f06d9f703e /Common/interface
parentFixed Mac/iOS build error (diff)
downloadDiligentCore-f6f030dbdc1b8cd636f1e340e506ae776b57999c.tar.gz
DiligentCore-f6f030dbdc1b8cd636f1e340e506ae776b57999c.zip
Optimized memory layout of ObjectBase<> (reduced size by 40 bytes on msvc x64)
Diffstat (limited to 'Common/interface')
-rw-r--r--Common/interface/UniqueIdentifier.h24
1 files changed, 8 insertions, 16 deletions
diff --git a/Common/interface/UniqueIdentifier.h b/Common/interface/UniqueIdentifier.h
index 1f3e2f60..18d11512 100644
--- a/Common/interface/UniqueIdentifier.h
+++ b/Common/interface/UniqueIdentifier.h
@@ -27,7 +27,7 @@
namespace Diligent
{
- typedef Atomics::Long UniqueIdentifier;
+ using UniqueIdentifier = Atomics::Long;
// Template switch is used to have distinct counters
// for unrelated groups of objects
@@ -36,44 +36,36 @@ namespace Diligent
{
public:
UniqueIdHelper() :
- m_ID(0),
- m_bIsInitialized( false )
+ m_ID(0)
{}
- UniqueIdHelper( UniqueIdHelper&& RHS) :
- m_ID( RHS.m_ID ),
- m_bIsInitialized( RHS.m_bIsInitialized )
+ UniqueIdHelper (const UniqueIdHelper&) = delete;
+ UniqueIdHelper& operator = (const UniqueIdHelper&) = delete;
+
+ UniqueIdHelper(UniqueIdHelper&& RHS) :
+ m_ID(RHS.m_ID)
{
RHS.m_ID = 0;
- RHS.m_bIsInitialized = false;
}
const UniqueIdHelper& operator = (UniqueIdHelper&& RHS)
{
m_ID = RHS.m_ID;
- m_bIsInitialized = RHS.m_bIsInitialized;
RHS.m_ID = 0;
- RHS.m_bIsInitialized = false;
-
return *this;
}
UniqueIdentifier GetID()const
{
- if( !m_bIsInitialized )
+ if (m_ID == 0)
{
static Atomics::AtomicLong sm_GlobalCounter;
m_ID = Atomics::AtomicIncrement(sm_GlobalCounter);
- m_bIsInitialized = true;
}
return m_ID;
}
private:
- UniqueIdHelper( const UniqueIdHelper& );
- const UniqueIdHelper& operator = ( const UniqueIdHelper& );
-
mutable UniqueIdentifier m_ID;
- mutable bool m_bIsInitialized;
};
}