Collections casts fix
This commit is contained in:
@@ -31,12 +31,12 @@ public:
|
||||
|
||||
FORCE_INLINE T* Get()
|
||||
{
|
||||
return (T*)_data;
|
||||
return reinterpret_cast<T*>(_data);
|
||||
}
|
||||
|
||||
FORCE_INLINE const T* Get() const
|
||||
{
|
||||
return (T*)_data;
|
||||
return reinterpret_cast<const T*>(_data);
|
||||
}
|
||||
|
||||
FORCE_INLINE int32 CalculateCapacityGrow(int32 capacity, const int32 minCapacity) const
|
||||
@@ -134,7 +134,7 @@ public:
|
||||
#if ENABLE_ASSERTION_LOW_LAYERS
|
||||
ASSERT(!_data);
|
||||
#endif
|
||||
_data = (T*)Allocator::Allocate(capacity * sizeof(T));
|
||||
_data = static_cast<T*>(Allocator::Allocate(capacity * sizeof(T)));
|
||||
#if !BUILD_RELEASE
|
||||
if (!_data)
|
||||
OUT_OF_MEMORY;
|
||||
@@ -143,7 +143,7 @@ public:
|
||||
|
||||
FORCE_INLINE void Relocate(const int32 capacity, int32 oldCount, int32 newCount)
|
||||
{
|
||||
T* newData = capacity != 0 ? (T*)Allocator::Allocate(capacity * sizeof(T)) : nullptr;
|
||||
T* newData = capacity != 0 ? static_cast<T*>(Allocator::Allocate(capacity * sizeof(T))) : nullptr;
|
||||
#if !BUILD_RELEASE
|
||||
if (!newData && capacity != 0)
|
||||
OUT_OF_MEMORY;
|
||||
@@ -203,12 +203,12 @@ public:
|
||||
|
||||
FORCE_INLINE T* Get()
|
||||
{
|
||||
return _useOther ? _other.Get() : (T*)_data;
|
||||
return _useOther ? _other.Get() : reinterpret_cast<T*>(_data);
|
||||
}
|
||||
|
||||
FORCE_INLINE const T* Get() const
|
||||
{
|
||||
return _useOther ? _other.Get() : (T*)_data;
|
||||
return _useOther ? _other.Get() : reinterpret_cast<const T*>(_data);
|
||||
}
|
||||
|
||||
FORCE_INLINE int32 CalculateCapacityGrow(int32 capacity, int32 minCapacity) const
|
||||
@@ -227,13 +227,15 @@ public:
|
||||
|
||||
FORCE_INLINE void Relocate(int32 capacity, int32 oldCount, int32 newCount)
|
||||
{
|
||||
T* data = reinterpret_cast<T*>(_data);
|
||||
|
||||
// Check if the new allocation will fit into inlined storage
|
||||
if (capacity <= Capacity)
|
||||
{
|
||||
if (_useOther)
|
||||
{
|
||||
// Move the items from other allocation to the inlined storage
|
||||
Memory::MoveItems((T*)_data, _other.Get(), newCount);
|
||||
Memory::MoveItems(data, _other.Get(), newCount);
|
||||
|
||||
// Free the other allocation
|
||||
Memory::DestructItems(_other.Get(), oldCount);
|
||||
@@ -255,8 +257,8 @@ public:
|
||||
_useOther = true;
|
||||
|
||||
// Move the items from the inlined storage to the other allocation
|
||||
Memory::MoveItems(_other.Get(), (T*)_data, newCount);
|
||||
Memory::DestructItems((T*)_data, oldCount);
|
||||
Memory::MoveItems(_other.Get(), data, newCount);
|
||||
Memory::DestructItems(data, oldCount);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user