Simple Improve Array
This commit is contained in:
@@ -202,24 +202,16 @@ protected:
|
|||||||
///when the new number of elements is smaller, the destructor will be called, but memory will not be freed, to reduce performance overhead of run-time memory (de)allocations.
|
///when the new number of elements is smaller, the destructor will be called, but memory will not be freed, to reduce performance overhead of run-time memory (de)allocations.
|
||||||
SIMD_FORCE_INLINE void resizeNoInitialize(int newsize)
|
SIMD_FORCE_INLINE void resizeNoInitialize(int newsize)
|
||||||
{
|
{
|
||||||
int curSize = size();
|
if (newsize > size())
|
||||||
|
|
||||||
if (newsize < curSize)
|
|
||||||
{
|
{
|
||||||
} else
|
reserve(newsize);
|
||||||
{
|
|
||||||
if (newsize > size())
|
|
||||||
{
|
|
||||||
reserve(newsize);
|
|
||||||
}
|
|
||||||
//leave this uninitialized
|
|
||||||
}
|
}
|
||||||
m_size = newsize;
|
m_size = newsize;
|
||||||
}
|
}
|
||||||
|
|
||||||
SIMD_FORCE_INLINE void resize(int newsize, const T& fillData=T())
|
SIMD_FORCE_INLINE void resize(int newsize, const T& fillData=T())
|
||||||
{
|
{
|
||||||
int curSize = size();
|
const register int curSize = size();
|
||||||
|
|
||||||
if (newsize < curSize)
|
if (newsize < curSize)
|
||||||
{
|
{
|
||||||
@@ -229,7 +221,7 @@ protected:
|
|||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
if (newsize > size())
|
if (newsize > curSize)
|
||||||
{
|
{
|
||||||
reserve(newsize);
|
reserve(newsize);
|
||||||
}
|
}
|
||||||
@@ -246,7 +238,7 @@ protected:
|
|||||||
}
|
}
|
||||||
SIMD_FORCE_INLINE T& expandNonInitializing( )
|
SIMD_FORCE_INLINE T& expandNonInitializing( )
|
||||||
{
|
{
|
||||||
int sz = size();
|
const register int sz = size();
|
||||||
if( sz == capacity() )
|
if( sz == capacity() )
|
||||||
{
|
{
|
||||||
reserve( allocSize(size()) );
|
reserve( allocSize(size()) );
|
||||||
@@ -259,7 +251,7 @@ protected:
|
|||||||
|
|
||||||
SIMD_FORCE_INLINE T& expand( const T& fillValue=T())
|
SIMD_FORCE_INLINE T& expand( const T& fillValue=T())
|
||||||
{
|
{
|
||||||
int sz = size();
|
const register int sz = size();
|
||||||
if( sz == capacity() )
|
if( sz == capacity() )
|
||||||
{
|
{
|
||||||
reserve( allocSize(size()) );
|
reserve( allocSize(size()) );
|
||||||
@@ -275,7 +267,7 @@ protected:
|
|||||||
|
|
||||||
SIMD_FORCE_INLINE void push_back(const T& _Val)
|
SIMD_FORCE_INLINE void push_back(const T& _Val)
|
||||||
{
|
{
|
||||||
int sz = size();
|
const register int sz = size();
|
||||||
if( sz == capacity() )
|
if( sz == capacity() )
|
||||||
{
|
{
|
||||||
reserve( allocSize(size()) );
|
reserve( allocSize(size()) );
|
||||||
|
|||||||
Reference in New Issue
Block a user