QVarLengthArray: simplify copy ctor implementation

std::tie(a, s, ptr) = {Prealloc, 0, (T*)array} is exactly the effects
of the default ctor, so just delegate to it, before calling
copyAppend().

Also clean up the copy ctor declaration (superfluous inline keyword,
and template arguments).

Change-Id: Iefc758a47996382fee10b1e081e44f008b146287
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Marc Mutz 2021-11-26 14:52:56 +01:00
parent 6855b80eae
commit 0265b923ac

View File

@ -67,8 +67,8 @@ public:
inline explicit QVarLengthArray(qsizetype size);
inline QVarLengthArray(const QVarLengthArray<T, Prealloc> &other)
: a(Prealloc), s(0), ptr(reinterpret_cast<T *>(array))
QVarLengthArray(const QVarLengthArray &other)
: QVarLengthArray{}
{
append(other.constData(), other.size());
}