Use std::destroy() instead if handwritten loop

Change-Id: Ia75296abf804332bb6f53dbb9a2eed8600b6e8b4
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
This commit is contained in:
Lars Knoll 2020-11-10 11:00:26 +01:00
parent 0b1ca7c001
commit 590d4b3443

View File

@ -509,10 +509,8 @@ public:
Q_ASSERT(!this->isShared()); Q_ASSERT(!this->isShared());
Q_ASSERT(newSize < size_t(this->size)); Q_ASSERT(newSize < size_t(this->size));
const T *const b = this->begin(); std::destroy(this->begin() + newSize, this->end());
do { this->size = newSize;
(b + --this->size)->~T();
} while (size_t(this->size) != newSize);
} }
void destroyAll() // Call from destructors, ONLY void destroyAll() // Call from destructors, ONLY
@ -523,11 +521,7 @@ public:
Q_ASSERT(this->d->ref_.loadRelaxed() == 0); Q_ASSERT(this->d->ref_.loadRelaxed() == 0);
const T *const b = this->begin(); std::destroy(this->begin(), this->end());
const T *i = this->end();
while (i != b)
(--i)->~T();
} }
void insert(GrowsForwardTag, T *where, const T *b, const T *e) void insert(GrowsForwardTag, T *where, const T *b, const T *e)