summaryrefslogtreecommitdiff
path: root/src/dynamic-array.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/dynamic-array.hpp')
-rw-r--r--src/dynamic-array.hpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/dynamic-array.hpp b/src/dynamic-array.hpp
index 6813edf..876f71d 100644
--- a/src/dynamic-array.hpp
+++ b/src/dynamic-array.hpp
@@ -195,8 +195,10 @@ template <typename T> inline void DynArray<T>::Reserve(int64_t count) {
template <typename T> inline void DynArray<T>::Resize(int64_t count) {
int64_t beforeCount = this->elementCount;
if IS_DESTRUCTIBLE(T) {
- for (long i = count; i > beforeCount; --i) {
- reinterpret_cast<T *>(this->ptr + (i * sizeof(T)))->~T();
+ if (beforeCount > count) {
+ for (long i = count; i > beforeCount; --i) {
+ reinterpret_cast<T *>(this->ptr + (i * sizeof(T)))->~T();
+ }
}
}
if (count > 0) {