diff options
author | Lars Knoll <lars.knoll@qt.io> | 2020-11-10 10:03:26 +0100 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2020-11-17 11:46:41 +0100 |
commit | 0b1ca7c00186295c8786c451b2ff82d2823304a0 (patch) | |
tree | 77cc24ab683186720d017fab5714c7ee3e522f50 /src/corelib/tools/qarraydataops.h | |
parent | d3db51ef4a11076b690e6e790bf01958b2ac4439 (diff) |
Clean up QCommonArrayOps
Remove methods that were just calling the base implementation.
Change-Id: I4011e1b7f4f2baad98bc2af2d4ddb134a66e1be2
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Diffstat (limited to 'src/corelib/tools/qarraydataops.h')
-rw-r--r-- | src/corelib/tools/qarraydataops.h | 52 |
1 files changed, 13 insertions, 39 deletions
diff --git a/src/corelib/tools/qarraydataops.h b/src/corelib/tools/qarraydataops.h index 9ad2d9acb9..0ac34ae5fb 100644 --- a/src/corelib/tools/qarraydataops.h +++ b/src/corelib/tools/qarraydataops.h @@ -244,9 +244,14 @@ public: void moveAppend(T *b, T *e) noexcept { - Q_ASSERT(b < e); + Q_ASSERT(this->isMutable() || b == e); + Q_ASSERT(!this->isShared() || b == e); + Q_ASSERT(b <= e); Q_ASSERT((e - b) <= this->freeSpaceAtEnd()); + if (b == e) + return; + ::memcpy(static_cast<void *>(this->end()), static_cast<const void *>(b), (e - b) * sizeof(T)); this->size += (e - b); } @@ -401,6 +406,7 @@ public: void eraseFirst() noexcept { + Q_ASSERT(this->isMutable()); Q_ASSERT(this->size); ++this->ptr; --this->size; @@ -408,6 +414,7 @@ public: void eraseLast() noexcept { + Q_ASSERT(this->isMutable()); Q_ASSERT(this->size); --this->size; } @@ -484,6 +491,9 @@ public: Q_ASSERT(b <= e); Q_ASSERT((e - b) <= this->freeSpaceAtEnd()); + if (b == e) + return; + typedef typename QArrayExceptionSafetyPrimitives<T>::Constructor CopyConstructor; // Provides strong exception safety guarantee, @@ -821,6 +831,7 @@ public: void eraseFirst() { + Q_ASSERT(this->isMutable()); Q_ASSERT(this->size); this->begin()->~T(); ++this->ptr; @@ -829,6 +840,7 @@ public: void eraseLast() { + Q_ASSERT(this->isMutable()); Q_ASSERT(this->size); (--this->end())->~T(); --this->size; @@ -1102,16 +1114,6 @@ public: // using Base::assign; // using Base::compare; - void appendInitialize(qsizetype newSize) - { - Q_ASSERT(this->isMutable()); - Q_ASSERT(!this->isShared()); - Q_ASSERT(newSize > this->size); - Q_ASSERT(newSize - this->size <= this->freeSpaceAtEnd()); - - Base::appendInitialize(newSize); - } - void copyAppend(const T *b, const T *e) { Q_ASSERT(this->isMutable() || b == e); @@ -1143,19 +1145,6 @@ public: } } - void moveAppend(T *b, T *e) - { - Q_ASSERT(this->isMutable() || b == e); - Q_ASSERT(!this->isShared() || b == e); - Q_ASSERT(b <= e); - Q_ASSERT((e - b) <= this->allocatedCapacity() - this->size); - - if (b == e) // short-cut and handling the case b and e == nullptr - return; - - Base::moveAppend(b, e); - } - void copyAppend(size_t n, parameter_type t) { Q_ASSERT(!this->isShared() || n == 0); @@ -1260,21 +1249,6 @@ public: --this->ptr; ++this->size; } - - void eraseFirst() - { - Q_ASSERT(this->isMutable()); - Q_ASSERT(this->size); - Base::eraseFirst(); - } - - void eraseLast() - { - Q_ASSERT(this->isMutable()); - Q_ASSERT(this->size); - Base::eraseLast(); - } - }; } // namespace QtPrivate |