diff options
Diffstat (limited to 'src/dynamic-array.hpp')
| -rw-r--r-- | src/dynamic-array.hpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/dynamic-array.hpp b/src/dynamic-array.hpp index f06ddac..6b22f6b 100644 --- a/src/dynamic-array.hpp +++ b/src/dynamic-array.hpp @@ -116,7 +116,7 @@ template <typename T> inline bool DynArray<T>::Has(const T &val) { template <typename T> inline void DynArray<T>::Push(const T &val) { if (this->elementCount + 1 > this->reservedCount) { - auto safeReserveCount = this->reservedCount == 0 ? 1 : this->reservedCount; + auto safeReserveCount = this->reservedCount < 2 ? 2 : this->reservedCount; DynArrayReserve(this, int64_t(safeReserveCount * 1.5)); } auto itemPtr = this->ptr + (sizeof(T) * this->elementCount); @@ -126,7 +126,7 @@ template <typename T> inline void DynArray<T>::Push(const T &val) { } template <typename T> inline T DynArray<T>::Pop() { - assert(this->elementCount == 0 && "Invalid DynArray<T>::Pop() - Contains no elements"); + assert(this->elementCount > 0 && "Invalid DynArray<T>::Pop() - Contains no elements"); this->elementCount -= 1; return *reinterpret_cast<T *>((this->ptr + (sizeof(T) * this->elementCount))); } |
