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>
This commit is contained in:
Lars Knoll 2020-11-10 10:03:26 +01:00
parent d3db51ef4a
commit 0b1ca7c001

View File

@ -244,9 +244,14 @@ public:
void moveAppend(T *b, T *e) noexcept 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()); 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)); ::memcpy(static_cast<void *>(this->end()), static_cast<const void *>(b), (e - b) * sizeof(T));
this->size += (e - b); this->size += (e - b);
} }
@ -401,6 +406,7 @@ public:
void eraseFirst() noexcept void eraseFirst() noexcept
{ {
Q_ASSERT(this->isMutable());
Q_ASSERT(this->size); Q_ASSERT(this->size);
++this->ptr; ++this->ptr;
--this->size; --this->size;
@ -408,6 +414,7 @@ public:
void eraseLast() noexcept void eraseLast() noexcept
{ {
Q_ASSERT(this->isMutable());
Q_ASSERT(this->size); Q_ASSERT(this->size);
--this->size; --this->size;
} }
@ -484,6 +491,9 @@ public:
Q_ASSERT(b <= e); Q_ASSERT(b <= e);
Q_ASSERT((e - b) <= this->freeSpaceAtEnd()); Q_ASSERT((e - b) <= this->freeSpaceAtEnd());
if (b == e)
return;
typedef typename QArrayExceptionSafetyPrimitives<T>::Constructor CopyConstructor; typedef typename QArrayExceptionSafetyPrimitives<T>::Constructor CopyConstructor;
// Provides strong exception safety guarantee, // Provides strong exception safety guarantee,
@ -821,6 +831,7 @@ public:
void eraseFirst() void eraseFirst()
{ {
Q_ASSERT(this->isMutable());
Q_ASSERT(this->size); Q_ASSERT(this->size);
this->begin()->~T(); this->begin()->~T();
++this->ptr; ++this->ptr;
@ -829,6 +840,7 @@ public:
void eraseLast() void eraseLast()
{ {
Q_ASSERT(this->isMutable());
Q_ASSERT(this->size); Q_ASSERT(this->size);
(--this->end())->~T(); (--this->end())->~T();
--this->size; --this->size;
@ -1102,16 +1114,6 @@ public:
// using Base::assign; // using Base::assign;
// using Base::compare; // 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) void copyAppend(const T *b, const T *e)
{ {
Q_ASSERT(this->isMutable() || b == 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) void copyAppend(size_t n, parameter_type t)
{ {
Q_ASSERT(!this->isShared() || n == 0); Q_ASSERT(!this->isShared() || n == 0);
@ -1260,21 +1249,6 @@ public:
--this->ptr; --this->ptr;
++this->size; ++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 } // namespace QtPrivate