diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp index 51b8379b3d0..12d76c0dcab 100644 --- a/src/corelib/global/qglobal.cpp +++ b/src/corelib/global/qglobal.cpp @@ -4030,10 +4030,8 @@ bool qunsetenv(const char *varName) \list \li \c Q_PRIMITIVE_TYPE specifies that \a Type is a POD (plain old - data) type with no constructor or destructor, or else a type where - every bit pattern is a valid object; memset()ting memory to zero - creates a value-initialized instance of the type; and memcpy()ing - creates a valid independent copy of an object. + data) type with no constructor or destructor, and for which memcpy()ing + creates a valid independent copy of the object. \li \c Q_MOVABLE_TYPE specifies that \a Type has a constructor and/or a destructor but can be moved in memory using \c memcpy(). Note: despite the name, this has nothing to do with move diff --git a/src/corelib/tools/qarraydataops.h b/src/corelib/tools/qarraydataops.h index 7e1b43f9b11..0579f78cacd 100644 --- a/src/corelib/tools/qarraydataops.h +++ b/src/corelib/tools/qarraydataops.h @@ -65,8 +65,10 @@ struct QPodArrayOps Q_ASSERT(newSize > uint(this->size)); Q_ASSERT(newSize <= this->alloc); - ::memset(static_cast(this->end()), 0, (newSize - this->size) * sizeof(T)); - this->size = int(newSize); + T *const begin = this->begin(); + do { + new (begin + this->size) T(); + } while (uint(++this->size) != newSize); } void copyAppend(const T *b, const T *e) @@ -154,7 +156,7 @@ struct QGenericArrayOps T *const begin = this->begin(); do { - new (begin + this->size) T; + new (begin + this->size) T(); } while (uint(++this->size) != newSize); } diff --git a/src/corelib/tools/qvector.h b/src/corelib/tools/qvector.h index 30fd7b28657..22a7a39faa3 100644 --- a/src/corelib/tools/qvector.h +++ b/src/corelib/tools/qvector.h @@ -323,13 +323,8 @@ private: template void QVector::defaultConstruct(T *from, T *to) { - if (QTypeInfo::isComplex) { - while (from != to) { - new (from++) T(); - } - } else { - ::memset(static_cast(from), 0, (to - from) * sizeof(T)); - } + while (from != to) + new (from++) T(); } template @@ -599,17 +594,13 @@ void QVector::reallocData(const int asize, const int aalloc, QArrayData::Allo if (asize > d->size) { // construct all new objects when growing - if (!QTypeInfo::isComplex) { - ::memset(static_cast(dst), 0, (static_cast(x->end()) - dst) * sizeof(T)); - } else { - QT_TRY { - while (dst != x->end()) - new (dst++) T(); - } QT_CATCH (...) { - // destruct already copied objects - destruct(x->begin(), dst); - QT_RETHROW; - } + QT_TRY { + while (dst != x->end()) + new (dst++) T(); + } QT_CATCH (...) { + // destruct already copied objects + destruct(x->begin(), dst); + QT_RETHROW; } } } QT_CATCH (...) {