From 0b1ca7c00186295c8786c451b2ff82d2823304a0 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Tue, 10 Nov 2020 10:03:26 +0100 Subject: [PATCH] Clean up QCommonArrayOps Remove methods that were just calling the base implementation. Change-Id: I4011e1b7f4f2baad98bc2af2d4ddb134a66e1be2 Reviewed-by: Thiago Macieira Reviewed-by: Andrei Golubev --- src/corelib/tools/qarraydataops.h | 52 ++++++++----------------------- 1 file changed, 13 insertions(+), 39 deletions(-) diff --git a/src/corelib/tools/qarraydataops.h b/src/corelib/tools/qarraydataops.h index 9ad2d9acb90..0ac34ae5fb7 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(this->end()), static_cast(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::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