diff options
author | Lars Knoll <lars.knoll@qt.io> | 2020-11-10 11:00:26 +0100 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2020-11-17 11:46:46 +0100 |
commit | 590d4b3443ee94425e4513ab20a40823ec5ed4e4 (patch) | |
tree | a87a93658776c2502608fce3c334a25a1c8a6720 /src | |
parent | 0b1ca7c00186295c8786c451b2ff82d2823304a0 (diff) |
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>
Diffstat (limited to 'src')
-rw-r--r-- | src/corelib/tools/qarraydataops.h | 12 |
1 files changed, 3 insertions, 9 deletions
diff --git a/src/corelib/tools/qarraydataops.h b/src/corelib/tools/qarraydataops.h index 0ac34ae5fb..e2ff3f676b 100644 --- a/src/corelib/tools/qarraydataops.h +++ b/src/corelib/tools/qarraydataops.h @@ -509,10 +509,8 @@ public: Q_ASSERT(!this->isShared()); Q_ASSERT(newSize < size_t(this->size)); - const T *const b = this->begin(); - do { - (b + --this->size)->~T(); - } while (size_t(this->size) != newSize); + std::destroy(this->begin() + newSize, this->end()); + this->size = newSize; } void destroyAll() // Call from destructors, ONLY @@ -523,11 +521,7 @@ public: Q_ASSERT(this->d->ref_.loadRelaxed() == 0); - const T *const b = this->begin(); - const T *i = this->end(); - - while (i != b) - (--i)->~T(); + std::destroy(this->begin(), this->end()); } void insert(GrowsForwardTag, T *where, const T *b, const T *e) |