Optimize Array::RemoveAtKeepOrder
This commit is contained in:
@@ -658,13 +658,7 @@ public:
|
|||||||
--_count;
|
--_count;
|
||||||
T* data = _allocation.Get();
|
T* data = _allocation.Get();
|
||||||
if (index < _count)
|
if (index < _count)
|
||||||
{
|
Memory::MoveAssignItems(data + index, data + (index + 1), _count - index);
|
||||||
T* dst = data + index;
|
|
||||||
T* src = data + (index + 1);
|
|
||||||
const int32 count = _count - index;
|
|
||||||
for (int32 i = 0; i < count; ++i)
|
|
||||||
dst[i] = MoveTemp(src[i]);
|
|
||||||
}
|
|
||||||
Memory::DestructItems(data + _count, 1);
|
Memory::DestructItems(data + _count, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -104,12 +104,6 @@ public:
|
|||||||
{
|
{
|
||||||
new(dst) T();
|
new(dst) T();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Constructs the item in the memory.
|
|
||||||
/// </summary>
|
|
||||||
/// <remarks>The optimized version is noop.</remarks>
|
|
||||||
/// <param name="dst">The address of the memory location to construct.</param>
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
FORCE_INLINE static typename TEnableIf<TIsTriviallyConstructible<T>::Value>::Type ConstructItem(T* dst)
|
FORCE_INLINE static typename TEnableIf<TIsTriviallyConstructible<T>::Value>::Type ConstructItem(T* dst)
|
||||||
{
|
{
|
||||||
@@ -132,13 +126,6 @@ public:
|
|||||||
++(T*&)dst;
|
++(T*&)dst;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Constructs the range of items in the memory.
|
|
||||||
/// </summary>
|
|
||||||
/// <remarks>The optimized version is noop.</remarks>
|
|
||||||
/// <param name="dst">The address of the first memory location to construct.</param>
|
|
||||||
/// <param name="count">The number of element to construct. Can be equal 0.</param>
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
FORCE_INLINE static typename TEnableIf<TIsTriviallyConstructible<T>::Value>::Type ConstructItems(T* dst, int32 count)
|
FORCE_INLINE static typename TEnableIf<TIsTriviallyConstructible<T>::Value>::Type ConstructItems(T* dst, int32 count)
|
||||||
{
|
{
|
||||||
@@ -163,14 +150,6 @@ public:
|
|||||||
++src;
|
++src;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Constructs the range of items in the memory from the set of arguments.
|
|
||||||
/// </summary>
|
|
||||||
/// <remarks>The optimized version uses low-level memory copy.</remarks>
|
|
||||||
/// <param name="dst">The address of the first memory location to construct.</param>
|
|
||||||
/// <param name="src">The address of the first memory location to pass to the constructor.</param>
|
|
||||||
/// <param name="count">The number of element to construct. Can be equal 0.</param>
|
|
||||||
template<typename T, typename U>
|
template<typename T, typename U>
|
||||||
FORCE_INLINE static typename TEnableIf<TIsBitwiseConstructible<T, U>::Value>::Type ConstructItems(T* dst, const U* src, int32 count)
|
FORCE_INLINE static typename TEnableIf<TIsBitwiseConstructible<T, U>::Value>::Type ConstructItems(T* dst, const U* src, int32 count)
|
||||||
{
|
{
|
||||||
@@ -187,12 +166,6 @@ public:
|
|||||||
{
|
{
|
||||||
dst->~T();
|
dst->~T();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Destructs the item in the memory.
|
|
||||||
/// </summary>
|
|
||||||
/// <remarks>The optimized version is noop.</remarks>
|
|
||||||
/// <param name="dst">The address of the memory location to destruct.</param>
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
FORCE_INLINE static typename TEnableIf<TIsTriviallyDestructible<T>::Value>::Type DestructItem(T* dst)
|
FORCE_INLINE static typename TEnableIf<TIsTriviallyDestructible<T>::Value>::Type DestructItem(T* dst)
|
||||||
{
|
{
|
||||||
@@ -213,13 +186,6 @@ public:
|
|||||||
++dst;
|
++dst;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Destructs the range of items in the memory.
|
|
||||||
/// </summary>
|
|
||||||
/// <remarks>The optimized version is noop.</remarks>
|
|
||||||
/// <param name="dst">The address of the first memory location to destruct.</param>
|
|
||||||
/// <param name="count">The number of element to destruct. Can be equal 0.</param>
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
FORCE_INLINE static typename TEnableIf<TIsTriviallyDestructible<T>::Value>::Type DestructItems(T* dst, int32 count)
|
FORCE_INLINE static typename TEnableIf<TIsTriviallyDestructible<T>::Value>::Type DestructItems(T* dst, int32 count)
|
||||||
{
|
{
|
||||||
@@ -242,15 +208,7 @@ public:
|
|||||||
++src;
|
++src;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
template<typename T, typename U>
|
||||||
/// <summary>
|
|
||||||
/// Copies the range of items using the assignment operator.
|
|
||||||
/// </summary>
|
|
||||||
/// <remarks>The optimized version is low-level memory copy.</remarks>
|
|
||||||
/// <param name="dst">The address of the first memory location to start assigning to.</param>
|
|
||||||
/// <param name="src">The address of the first memory location to assign from.</param>
|
|
||||||
/// <param name="count">The number of element to assign. Can be equal 0.</param>
|
|
||||||
template<typename T>
|
|
||||||
FORCE_INLINE static typename TEnableIf<TIsTriviallyCopyAssignable<T>::Value>::Type CopyItems(T* dst, const T* src, int32 count)
|
FORCE_INLINE static typename TEnableIf<TIsTriviallyCopyAssignable<T>::Value>::Type CopyItems(T* dst, const T* src, int32 count)
|
||||||
{
|
{
|
||||||
Platform::MemoryCopy(dst, src, count * sizeof(T));
|
Platform::MemoryCopy(dst, src, count * sizeof(T));
|
||||||
@@ -273,16 +231,31 @@ public:
|
|||||||
++src;
|
++src;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
template<typename T, typename U>
|
||||||
|
FORCE_INLINE static typename TEnableIf<TIsBitwiseConstructible<T, U>::Value>::Type MoveItems(T* dst, U* src, int32 count)
|
||||||
|
{
|
||||||
|
Platform::MemoryCopy(dst, src, count * sizeof(U));
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Moves the range of items in the memory from the set of arguments.
|
/// Moves the range of items using the assignment operator.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <remarks>The optimized version uses low-level memory copy.</remarks>
|
/// <remarks>The optimized version uses low-level memory copy.</remarks>
|
||||||
/// <param name="dst">The address of the first memory location to move.</param>
|
/// <param name="dst">The address of the first memory location to move.</param>
|
||||||
/// <param name="src">The address of the first memory location to pass to the move constructor.</param>
|
/// <param name="src">The address of the first memory location to pass to the move constructor.</param>
|
||||||
/// <param name="count">The number of element to move. Can be equal 0.</param>
|
/// <param name="count">The number of element to move. Can be equal 0.</param>
|
||||||
template<typename T, typename U>
|
template<typename T, typename U>
|
||||||
FORCE_INLINE static typename TEnableIf<TIsBitwiseConstructible<T, U>::Value>::Type MoveItems(T* dst, U* src, int32 count)
|
FORCE_INLINE static typename TEnableIf<!TIsBitwiseConstructible<T, U>::Value>::Type MoveAssignItems(T* dst, U* src, int32 count)
|
||||||
|
{
|
||||||
|
while (count--)
|
||||||
|
{
|
||||||
|
*dst = MoveTemp(*src);
|
||||||
|
++(T*&)dst;
|
||||||
|
++src;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
template<typename T, typename U>
|
||||||
|
FORCE_INLINE static typename TEnableIf<TIsBitwiseConstructible<T, U>::Value>::Type MoveAssignItems(T* dst, U* src, int32 count)
|
||||||
{
|
{
|
||||||
Platform::MemoryCopy(dst, src, count * sizeof(U));
|
Platform::MemoryCopy(dst, src, count * sizeof(U));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user