From 1c33c37d4c237a1e43b431f95a827dd219a1f10a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9rgio=20Martins?= Date: Tue, 21 Apr 2015 21:32:19 +0100 Subject: QVector: Save one copy-CTOR call if we don't realloc Change-Id: Ie0f2eb922500bc3d76852939cf2c5d28d65a43ae Reviewed-by: Olivier Goffart (Woboq GmbH) --- src/corelib/tools/qvector.h | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'src/corelib/tools') diff --git a/src/corelib/tools/qvector.h b/src/corelib/tools/qvector.h index 9d5b749e79..eed5d17cad 100644 --- a/src/corelib/tools/qvector.h +++ b/src/corelib/tools/qvector.h @@ -600,16 +600,23 @@ Q_OUTOFLINE_TEMPLATE T QVector::value(int i, const T &defaultValue) const template void QVector::append(const T &t) { - const T copy(t); const bool isTooSmall = uint(d->size + 1) > d->alloc; if (!isDetached() || isTooSmall) { + const T copy(t); QArrayData::AllocationOptions opt(isTooSmall ? QArrayData::Grow : QArrayData::Default); reallocData(d->size, isTooSmall ? d->size + 1 : d->alloc, opt); + + if (QTypeInfo::isComplex) + new (d->end()) T(copy); + else + *d->end() = copy; + + } else { + if (QTypeInfo::isComplex) + new (d->end()) T(t); + else + *d->end() = t; } - if (QTypeInfo::isComplex) - new (d->end()) T(copy); - else - *d->end() = copy; ++d->size; } -- cgit v1.2.3 From b71535a9236a33371da36d89d38872d3ae91fbf0 Mon Sep 17 00:00:00 2001 From: Topi Reinio Date: Fri, 17 Apr 2015 14:32:02 +0200 Subject: Doc: Bring QSizeF/QPointF::isNull() documentation up to date Since Qt 5.0 (commit 09dd19df) sign is ignored when testing whether a QPointF or QSizeF is null. This updates the documentation accordingly. Change-Id: I3de1c748f3caa63b8bd8990006de5ba572eac83e Task-number: QTBUG-45669 Reviewed-by: Mitch Curtis Reviewed-by: Venugopal Shivashankar --- src/corelib/tools/qpoint.cpp | 8 ++------ src/corelib/tools/qsize.cpp | 8 ++------ 2 files changed, 4 insertions(+), 12 deletions(-) (limited to 'src/corelib/tools') diff --git a/src/corelib/tools/qpoint.cpp b/src/corelib/tools/qpoint.cpp index dc2a2d9739..94a245375b 100644 --- a/src/corelib/tools/qpoint.cpp +++ b/src/corelib/tools/qpoint.cpp @@ -528,12 +528,8 @@ QDebug operator<<(QDebug dbg, const QPointF &p) /*! \fn bool QPointF::isNull() const - Returns \c true if both the x and y coordinates are set to +0.0; - otherwise returns \c false. - - \note Since this function treats +0.0 and -0.0 differently, points - with zero-valued coordinates where either or both values have a - negative sign are not defined to be null points. + Returns \c true if both the x and y coordinates are set to 0.0 (ignoring + the sign); otherwise returns \c false. */ diff --git a/src/corelib/tools/qsize.cpp b/src/corelib/tools/qsize.cpp index 19227432f2..24a29f0213 100644 --- a/src/corelib/tools/qsize.cpp +++ b/src/corelib/tools/qsize.cpp @@ -517,12 +517,8 @@ QDebug operator<<(QDebug dbg, const QSize &s) /*! \fn bool QSizeF::isNull() const - Returns \c true if both the width and height are +0.0; otherwise returns - false. - - \note Since this function treats +0.0 and -0.0 differently, sizes with - zero width and height where either or both values have a negative - sign are not defined to be null sizes. + Returns \c true if both the width and height are 0.0 (ignoring the sign); + otherwise returns \c false. \sa isValid(), isEmpty() */ -- cgit v1.2.3