mirror of
https://bitbucket.org/smil3y/katie.git
synced 2025-02-23 10:22:55 +00:00
drop QVarLengthArray<T> and replace it with QStdVector<T> internally
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
4474d26443
commit
bdd67963ec
57 changed files with 168 additions and 1714 deletions
|
@ -148,7 +148,6 @@ include/katie/QtCore/QTimerEvent
|
|||
include/katie/QtCore/QTranslator
|
||||
include/katie/QtCore/QTypeInfo
|
||||
include/katie/QtCore/QUrl
|
||||
include/katie/QtCore/QVarLengthArray
|
||||
include/katie/QtCore/QVariant
|
||||
include/katie/QtCore/QVariantHash
|
||||
include/katie/QtCore/QVariantList
|
||||
|
@ -258,7 +257,6 @@ include/katie/QtCore/qtimer.h
|
|||
include/katie/QtCore/qtranslator.h
|
||||
include/katie/QtCore/qurl.h
|
||||
include/katie/QtCore/qvariant.h
|
||||
include/katie/QtCore/qvarlengtharray.h
|
||||
include/katie/QtCore/qvector.h
|
||||
include/katie/QtCore/qwaitcondition.h
|
||||
include/katie/QtDBus/QDBusAbstractAdaptor
|
||||
|
|
|
@ -585,7 +585,6 @@ classlist = [
|
|||
"QUrl",
|
||||
"QVBoxLayout",
|
||||
"QValidator",
|
||||
"QVarLengthArray",
|
||||
"QVariant",
|
||||
"QVariantAnimation",
|
||||
"QVariantHash",
|
||||
|
|
|
@ -9,7 +9,6 @@ set(EXTRA_CORE_LIBS
|
|||
)
|
||||
|
||||
set(CORE_PUBLIC_HEADERS
|
||||
QVarLengthArray
|
||||
QList
|
||||
QProcess
|
||||
QBuffer
|
||||
|
@ -214,7 +213,6 @@ set(CORE_HEADERS
|
|||
${CMAKE_CURRENT_SOURCE_DIR}/tools/qtextboundaryfinder.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/tools/qtimeline.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/tools/qelapsedtimer.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/tools/qvarlengtharray.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/tools/qvector.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/tools/qiterator.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/tools/qpair.h
|
||||
|
|
|
@ -24,13 +24,13 @@
|
|||
|
||||
#include "qlist.h"
|
||||
#include "qfile.h"
|
||||
#include "qvarlengtharray.h"
|
||||
#include "qstringlist.h"
|
||||
#include "qlocale.h"
|
||||
#include "qlocale_tools_p.h"
|
||||
#include "qtextcodec_p.h"
|
||||
#include "qmutex.h"
|
||||
#include "qhash.h"
|
||||
#include "qstdcontainers_p.h"
|
||||
#include "qcorecommon_p.h"
|
||||
#include "qdebug.h"
|
||||
|
||||
|
@ -1091,7 +1091,7 @@ QString QTextCodecPrivate::convertTo(const char *data, int length, const char* c
|
|||
ucnv_setSubstString(conv, questionmarkchar, 1, &error);
|
||||
|
||||
const int maxbytes = UCNV_GET_MAX_BYTES_FOR_STRING(length, ucnv_getMaxCharSize(conv));
|
||||
QVarLengthArray<UChar> result(maxbytes);
|
||||
QStdVector<UChar> result(maxbytes);
|
||||
error = U_ZERO_ERROR;
|
||||
const int convresult = ucnv_toUChars(conv, result.data(), maxbytes, data, length, &error);
|
||||
ucnv_close(conv);
|
||||
|
@ -1115,7 +1115,7 @@ QByteArray QTextCodecPrivate::convertFrom(const QChar *unicode, int length, cons
|
|||
ucnv_setSubstString(conv, questionmarkchar, 1, &error);
|
||||
|
||||
const int maxbytes = UCNV_GET_MAX_BYTES_FOR_STRING(length, ucnv_getMaxCharSize(conv));
|
||||
QVarLengthArray<char> result(maxbytes);
|
||||
QStdVector<char> result(maxbytes);
|
||||
error = U_ZERO_ERROR;
|
||||
const int convresult = ucnv_fromUChars(conv, result.data(), maxbytes,
|
||||
reinterpret_cast<const UChar *>(unicode), length, &error);
|
||||
|
@ -1954,7 +1954,7 @@ QByteArray QTextConverter::fromUnicode(const QChar *data, int length) const
|
|||
}
|
||||
|
||||
const int maxbytes = UCNV_GET_MAX_BYTES_FOR_STRING(length, ucnv_getMaxCharSize(conv));
|
||||
QVarLengthArray<char> result(maxbytes);
|
||||
QStdVector<char> result(maxbytes);
|
||||
UErrorCode error = U_ZERO_ERROR;
|
||||
const int convresult = ucnv_fromUChars(conv, result.data(), maxbytes,
|
||||
reinterpret_cast<const UChar *>(data), length, &error);
|
||||
|
@ -1974,7 +1974,7 @@ QString QTextConverter::toUnicode(const char *data, int length) const
|
|||
}
|
||||
|
||||
const int maxbytes = UCNV_GET_MAX_BYTES_FOR_STRING(length, ucnv_getMaxCharSize(conv));
|
||||
QVarLengthArray<UChar> result(maxbytes);
|
||||
QStdVector<UChar> result(maxbytes);
|
||||
UErrorCode error = U_ZERO_ERROR;
|
||||
const int convresult = ucnv_toUChars(conv, result.data(), maxbytes, data, length, &error);
|
||||
// regardless if the data has BOM or not, BOMs shall be generated explicitly only by QTextStream
|
||||
|
|
|
@ -34,8 +34,8 @@
|
|||
#include "qfilesystementry_p.h"
|
||||
#include "qfilesystemmetadata_p.h"
|
||||
#include "qfilesystemengine_p.h"
|
||||
#include "qvarlengtharray.h"
|
||||
#include "qscopedpointer.h"
|
||||
#include "qstdcontainers_p.h"
|
||||
#include "qcorecommon_p.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
@ -212,7 +212,7 @@ inline void QDirPrivate::sortFileList(QDir::SortFlags sort, QFileInfoList &l,
|
|||
names->append(l.at(i).fileName());
|
||||
}
|
||||
} else {
|
||||
QVarLengthArray<QDirSortItem> si(n);
|
||||
QStdVector<QDirSortItem> si(n);
|
||||
for (int i = 0; i < n; ++i)
|
||||
si[i].item = l.at(i);
|
||||
qSort(si.data(), si.data() + n, QDirSortItemComparator(sort));
|
||||
|
|
|
@ -36,7 +36,6 @@
|
|||
#include "qthreadpool.h"
|
||||
#include "qstandardpaths.h"
|
||||
#include "qelapsedtimer.h"
|
||||
#include "qvarlengtharray.h"
|
||||
#include "qscopedpointer.h"
|
||||
#include "qlibraryinfo.h"
|
||||
#include "qthread_p.h"
|
||||
|
@ -44,8 +43,8 @@
|
|||
#include "qfactoryloader_p.h"
|
||||
#include "qlocale_p.h"
|
||||
#include "qeventdispatcher_unix_p.h"
|
||||
#include "qcorecommon_p.h"
|
||||
#include "qstdcontainers_p.h"
|
||||
#include "qcorecommon_p.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
|
@ -1061,7 +1060,7 @@ void QCoreApplication::removePostedEvents(QObject *receiver, int eventType)
|
|||
|
||||
//we will collect all the posted events for the QObject
|
||||
//and we'll delete after the mutex was unlocked
|
||||
QVarLengthArray<QEvent*> events;
|
||||
QStdVector<QEvent*> events;
|
||||
int n = data->postEventList.size();
|
||||
int j = 0;
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
#include "QtCore/qabstracteventdispatcher.h"
|
||||
#include "qabstracteventdispatcher_p.h"
|
||||
#include "qcore_unix_p.h"
|
||||
#include "qvarlengtharray.h"
|
||||
#include "qstdcontainers_p.h"
|
||||
|
||||
#include <sys/time.h>
|
||||
#include <sys/select.h>
|
||||
|
@ -98,7 +98,7 @@ public:
|
|||
QSockNotType();
|
||||
~QSockNotType();
|
||||
|
||||
typedef QVarLengthArray<QSockNot*> List;
|
||||
typedef QStdVector<QSockNot*> List;
|
||||
|
||||
List list;
|
||||
fd_set select_fds;
|
||||
|
|
|
@ -22,19 +22,17 @@
|
|||
#include "qmetaobject.h"
|
||||
#include "qmetatype.h"
|
||||
#include "qobject.h"
|
||||
|
||||
#include "qcoreapplication.h"
|
||||
#include "qcoreevent.h"
|
||||
#include "qdatastream.h"
|
||||
#include "qthread.h"
|
||||
#include "qvarlengtharray.h"
|
||||
#include "qvariant.h"
|
||||
#include "qhash.h"
|
||||
#include "qdebug.h"
|
||||
#include "qsemaphore.h"
|
||||
|
||||
#include "qobject_p.h"
|
||||
#include "qmetaobject_p.h"
|
||||
#include "qstdcontainers_p.h"
|
||||
|
||||
#include <ctype.h>
|
||||
|
||||
|
@ -153,7 +151,8 @@ QObject *QMetaObject::newInstance(QGenericArgument val0,
|
|||
if (idx != -1)
|
||||
constructorName.remove(0, idx+1); // remove qualified part
|
||||
}
|
||||
QVarLengthArray<char> sig;
|
||||
QByteArray sig;
|
||||
sig.reserve(constructorName.length() + 1);
|
||||
sig.append(constructorName.constData(), constructorName.length());
|
||||
sig.append('(');
|
||||
|
||||
|
@ -1049,13 +1048,16 @@ bool QMetaObject::invokeMethod(QObject *obj,
|
|||
int len = qstrlen(member);
|
||||
if (len <= 0)
|
||||
return false;
|
||||
QVarLengthArray<char> sig;
|
||||
QByteArray sig;
|
||||
sig.reserve(len + 1);
|
||||
sig.append(member, len);
|
||||
sig.append('(');
|
||||
|
||||
const char *typeNames[] = {ret.name(), val0.name(), val1.name(), val2.name(), val3.name(),
|
||||
val4.name(), val5.name(), val6.name(), val7.name(), val8.name(),
|
||||
val9.name()};
|
||||
const char *typeNames[] = {
|
||||
ret.name(), val0.name(), val1.name(), val2.name(), val3.name(),
|
||||
val4.name(), val5.name(), val6.name(), val7.name(), val8.name(),
|
||||
val9.name()
|
||||
};
|
||||
|
||||
int paramCount;
|
||||
for (paramCount = 1; paramCount < MaximumParamCount; ++paramCount) {
|
||||
|
|
|
@ -2067,7 +2067,7 @@ bool QObject::connect(const QObject *sender, const QMetaMethod &signal,
|
|||
return false;
|
||||
}
|
||||
|
||||
QVarLengthArray<char> signalSignature;
|
||||
QStdVector<char> signalSignature;
|
||||
QObjectPrivate::signalSignature(signal, &signalSignature);
|
||||
|
||||
int signal_index;
|
||||
|
@ -2319,7 +2319,7 @@ bool QObject::disconnect(const QObject *sender, const QMetaMethod &signal,
|
|||
}
|
||||
}
|
||||
|
||||
QVarLengthArray<char> signalSignature;
|
||||
QStdVector<char> signalSignature;
|
||||
if (signal.mobj)
|
||||
QObjectPrivate::signalSignature(signal, &signalSignature);
|
||||
|
||||
|
|
|
@ -33,11 +33,11 @@
|
|||
// We mean it.
|
||||
//
|
||||
|
||||
#include "QtCore/qpointer.h"
|
||||
#include "QtCore/qsharedpointer.h"
|
||||
#include "QtCore/qcoreevent.h"
|
||||
#include "QtCore/qmetaobject.h"
|
||||
#include "QtCore/qvarlengtharray.h"
|
||||
#include "qpointer.h"
|
||||
#include "qsharedpointer.h"
|
||||
#include "qcoreevent.h"
|
||||
#include "qmetaobject.h"
|
||||
#include "qstdcontainers_p.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
|
@ -141,7 +141,7 @@ public:
|
|||
inline void disconnectNotify(const char *signal);
|
||||
|
||||
static inline void signalSignature(const QMetaMethod &signal,
|
||||
QVarLengthArray<char> *result);
|
||||
QStdVector<char> *result);
|
||||
|
||||
public:
|
||||
QString objectName;
|
||||
|
@ -192,17 +192,21 @@ inline void QObjectPrivate::disconnectNotify(const char *signal)
|
|||
}
|
||||
|
||||
inline void QObjectPrivate::signalSignature(const QMetaMethod &signal,
|
||||
QVarLengthArray<char> *result)
|
||||
QStdVector<char> *result)
|
||||
{
|
||||
Q_ASSERT(result);
|
||||
const int signatureLength = qstrlen(signal.signature());
|
||||
const char* signatureData = signal.signature();
|
||||
const int signatureLength = qstrlen(signatureData);
|
||||
if (signatureLength == 0) {
|
||||
result->append((char)0);
|
||||
return;
|
||||
}
|
||||
result->reserve(signatureLength + 2);
|
||||
result->append((char)(QSIGNAL_CODE + '0'));
|
||||
result->append(signal.signature(), signatureLength + 1);
|
||||
for (int i = 0; i < signatureLength; i++) {
|
||||
result->append(signatureData[i]);
|
||||
}
|
||||
result->append('\0');
|
||||
}
|
||||
|
||||
inline QObjectPrivate::Sender *QObjectPrivate::setCurrentSender(QObject *receiver,
|
||||
|
|
|
@ -37,7 +37,6 @@ template <class T1, class T2> struct QPair;
|
|||
template <class T> class QQueue;
|
||||
template <class T> class QSet;
|
||||
template <class T> class QStack;
|
||||
template<class T> class QVarLengthArray;
|
||||
template <class T> class QVector;
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
|
|
@ -33,12 +33,10 @@
|
|||
// We mean it.
|
||||
//
|
||||
|
||||
#include "QtCore/qstring.h"
|
||||
#include "QtCore/qvarlengtharray.h"
|
||||
#include "QtCore/qmetatype.h"
|
||||
|
||||
#include "qstring.h"
|
||||
#include "qmetatype.h"
|
||||
#include "qlocale.h"
|
||||
|
||||
#include "qstdcontainers_p.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
|
@ -131,7 +129,7 @@ public:
|
|||
static qint64 bytearrayToLongLong(const char *num, int base, bool *ok);
|
||||
static quint64 bytearrayToUnsLongLong(const char *num, int base, bool *ok);
|
||||
|
||||
typedef QVarLengthArray<char> CharBuff;
|
||||
typedef QStdVector<char> CharBuff;
|
||||
bool numberToCLocale(const QString &num,
|
||||
GroupSeparatorMode group_sep_mode,
|
||||
CharBuff *result) const;
|
||||
|
|
|
@ -28,12 +28,12 @@
|
|||
#include "qlocale_p.h"
|
||||
#include "qlocale_tools_p.h"
|
||||
#include "qstringmatcher.h"
|
||||
#include "qvarlengtharray.h"
|
||||
#include "qhash.h"
|
||||
#include "qdebug.h"
|
||||
#include "qendian.h"
|
||||
#include "qmutex.h"
|
||||
#include "qbitarray.h"
|
||||
#include "qstdcontainers_p.h"
|
||||
#include "qcorecommon_p.h"
|
||||
|
||||
#ifndef QT_NO_TEXTCODEC
|
||||
|
@ -1666,11 +1666,11 @@ QString &QString::replace(const QLatin1String &before,
|
|||
Qt::CaseSensitivity cs)
|
||||
{
|
||||
int alen = qstrlen(after.latin1());
|
||||
QVarLengthArray<ushort> a(alen);
|
||||
QStdVector<ushort> a(alen);
|
||||
for (int i = 0; i < alen; ++i)
|
||||
a[i] = (uchar)after.latin1()[i];
|
||||
int blen = qstrlen(before.latin1());
|
||||
QVarLengthArray<ushort> b(blen);
|
||||
QStdVector<ushort> b(blen);
|
||||
for (int i = 0; i < blen; ++i)
|
||||
b[i] = (uchar)before.latin1()[i];
|
||||
return replace(reinterpret_cast<const QChar*>(b.constData()), blen, reinterpret_cast<const QChar*>(a.constData()), alen, cs);
|
||||
|
@ -1693,7 +1693,7 @@ QString &QString::replace(const QLatin1String &before,
|
|||
Qt::CaseSensitivity cs)
|
||||
{
|
||||
int blen = qstrlen(before.latin1());
|
||||
QVarLengthArray<ushort> b(blen);
|
||||
QStdVector<ushort> b(blen);
|
||||
for (int i = 0; i < blen; ++i)
|
||||
b[i] = (uchar)before.latin1()[i];
|
||||
return replace((const QChar *)b.data(), blen, after.constData(), after.d->size, cs);
|
||||
|
@ -1716,7 +1716,7 @@ QString &QString::replace(const QString &before,
|
|||
Qt::CaseSensitivity cs)
|
||||
{
|
||||
int alen = qstrlen(after.latin1());
|
||||
QVarLengthArray<ushort> a(alen);
|
||||
QStdVector<ushort> a(alen);
|
||||
for (int i = 0; i < alen; ++i)
|
||||
a[i] = (uchar)after.latin1()[i];
|
||||
return replace(before.constData(), before.d->size, (const QChar *)a.data(), alen, cs);
|
||||
|
@ -1737,7 +1737,7 @@ QString &QString::replace(const QString &before,
|
|||
QString &QString::replace(QChar c, const QLatin1String &after, Qt::CaseSensitivity cs)
|
||||
{
|
||||
int alen = qstrlen(after.latin1());
|
||||
QVarLengthArray<ushort> a(alen);
|
||||
QStdVector<ushort> a(alen);
|
||||
for (int i = 0; i < alen; ++i)
|
||||
a[i] = (uchar)after.latin1()[i];
|
||||
return replace(&c, 1, (const QChar *)a.data(), alen, cs);
|
||||
|
@ -2324,7 +2324,7 @@ int QString::lastIndexOf(const QLatin1String &str, int from, Qt::CaseSensitivity
|
|||
if (from > delta)
|
||||
from = delta;
|
||||
|
||||
QVarLengthArray<ushort> s(sl);
|
||||
QStdVector<ushort> s(sl);
|
||||
for (int i = 0; i < sl; ++i)
|
||||
s[i] = str.latin1()[i];
|
||||
|
||||
|
@ -3144,7 +3144,7 @@ static QByteArray toLatin1_helper(const QChar *data, int length)
|
|||
if (!length) {
|
||||
return QByteArray();
|
||||
}
|
||||
QVarLengthArray<char> result(length);
|
||||
QStdVector<char> result(length);
|
||||
for (int i = 0; i < length; i++) {
|
||||
const ushort ucs = data[i].unicode();
|
||||
result[i] = (ucs > 0xff) ? '?' : char(ucs);
|
||||
|
@ -3501,7 +3501,7 @@ QString QString::simplified() const
|
|||
if (d->size == 0)
|
||||
return *this;
|
||||
|
||||
QVarLengthArray<QChar> result(d->size);
|
||||
QStdVector<QChar> result(d->size);
|
||||
const QChar *from = reinterpret_cast<const QChar*>(d->data);
|
||||
const QChar *fromend = from + d->size;
|
||||
int outc = 0;
|
||||
|
@ -4295,7 +4295,7 @@ QString QString::toLower() const
|
|||
|
||||
UErrorCode error = U_ZERO_ERROR;
|
||||
const int maxchars = d->size + 1; // ICU will write zero-terminator
|
||||
QVarLengthArray<UChar> result(maxchars);
|
||||
QStdVector<UChar> result(maxchars);
|
||||
const int lowerresult = u_strToLower(result.data(), maxchars,
|
||||
reinterpret_cast<const UChar*>(d->data), d->size, "C", &error);
|
||||
if (Q_UNLIKELY(lowerresult > maxchars || U_FAILURE(error))) {
|
||||
|
@ -4315,7 +4315,7 @@ QString QString::toCaseFolded() const
|
|||
}
|
||||
UErrorCode error = U_ZERO_ERROR;
|
||||
const int maxchars = d->size + 1; // ICU will write zero-terminator
|
||||
QVarLengthArray<UChar> result(maxchars);
|
||||
QStdVector<UChar> result(maxchars);
|
||||
const int foldresult = u_strFoldCase(result.data(), maxchars,
|
||||
reinterpret_cast<const UChar*>(d->data), d->size, U_FOLD_CASE_DEFAULT, &error);
|
||||
if (Q_UNLIKELY(foldresult > maxchars || U_FAILURE(error))) {
|
||||
|
@ -4342,7 +4342,7 @@ QString QString::toUpper() const
|
|||
}
|
||||
UErrorCode error = U_ZERO_ERROR;
|
||||
const int maxchars = d->size + 1; // ICU will write zero-terminator
|
||||
QVarLengthArray<UChar> result(maxchars);
|
||||
QStdVector<UChar> result(maxchars);
|
||||
const int upperresult = u_strToUpper(result.data(), maxchars,
|
||||
reinterpret_cast<const UChar*>(d->data), d->size, "C", &error);
|
||||
if (Q_UNLIKELY(upperresult > maxchars || U_FAILURE(error))) {
|
||||
|
@ -7653,7 +7653,7 @@ int QStringRef::lastIndexOf(QLatin1String str, int from, Qt::CaseSensitivity cs)
|
|||
if (from > delta)
|
||||
from = delta;
|
||||
|
||||
QVarLengthArray<ushort> s(sl);
|
||||
QStdVector<ushort> s(sl);
|
||||
for (int i = 0; i < sl; ++i)
|
||||
s[i] = str.latin1()[i];
|
||||
|
||||
|
@ -7987,7 +7987,7 @@ static inline int qt_find_latin1_string(const QChar *haystack, int size,
|
|||
{
|
||||
const char *latin1 = needle.latin1();
|
||||
int len = qstrlen(latin1);
|
||||
QVarLengthArray<ushort> s(len);
|
||||
QStdVector<ushort> s(len);
|
||||
for (int i = 0; i < len; ++i)
|
||||
s[i] = latin1[i];
|
||||
|
||||
|
|
|
@ -1,381 +0,0 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2015 The Qt Company Ltd.
|
||||
** Copyright (C) 2016 Ivailo Monev
|
||||
**
|
||||
** This file is part of the QtCore module of the Katie Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QVARLENGTHARRAY_H
|
||||
#define QVARLENGTHARRAY_H
|
||||
|
||||
#include <QtCore/qalgorithms.h>
|
||||
|
||||
#include <new>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
template<class T>
|
||||
class Q_CORE_EXPORT QVarLengthArray
|
||||
{
|
||||
public:
|
||||
inline explicit QVarLengthArray(int size = 0);
|
||||
|
||||
inline QVarLengthArray(const QVarLengthArray<T> &other)
|
||||
: a(0), s(0), ptr(nullptr)
|
||||
{
|
||||
append(other.constData(), other.size());
|
||||
}
|
||||
|
||||
inline ~QVarLengthArray() {
|
||||
if (QTypeInfo<T>::isComplex) {
|
||||
T *i = ptr + s;
|
||||
while (i-- != ptr) {
|
||||
i->~T();
|
||||
}
|
||||
}
|
||||
if (ptr) {
|
||||
::free(ptr);
|
||||
}
|
||||
}
|
||||
inline QVarLengthArray<T> &operator=(const QVarLengthArray<T> &other)
|
||||
{
|
||||
if (this != &other) {
|
||||
clear();
|
||||
append(other.constData(), other.size());
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline void removeLast() {
|
||||
Q_ASSERT(s > 0);
|
||||
reallocData(s - 1, a);
|
||||
}
|
||||
inline int size() const { return s; }
|
||||
inline int count() const { return s; }
|
||||
inline bool isEmpty() const { return (s == 0); }
|
||||
inline void resize(int size);
|
||||
inline void clear() { resize(0); }
|
||||
|
||||
inline int capacity() const { return a; }
|
||||
inline void reserve(int size);
|
||||
|
||||
inline T &operator[](int idx) {
|
||||
Q_ASSERT(idx >= 0 && idx < s);
|
||||
return ptr[idx];
|
||||
}
|
||||
inline const T &operator[](int idx) const {
|
||||
Q_ASSERT(idx >= 0 && idx < s);
|
||||
return ptr[idx];
|
||||
}
|
||||
inline const T &at(int idx) const { return operator[](idx); }
|
||||
|
||||
T value(int i) const;
|
||||
T value(int i, const T &defaultValue) const;
|
||||
|
||||
inline void append(const T &t) {
|
||||
const int newSize = s + 1;
|
||||
if (newSize > a) {
|
||||
reallocData(s, newSize);
|
||||
}
|
||||
const int idx = s++;
|
||||
if (QTypeInfo<T>::isComplex) {
|
||||
new (ptr + idx) T(t);
|
||||
} else {
|
||||
ptr[idx] = t;
|
||||
}
|
||||
}
|
||||
void append(const T *buf, int size);
|
||||
inline QVarLengthArray<T> &operator<<(const T &t)
|
||||
{ append(t); return *this; }
|
||||
inline QVarLengthArray<T> &operator+=(const T &t)
|
||||
{ append(t); return *this; }
|
||||
|
||||
void prepend(const T &t);
|
||||
void insert(int i, const T &t);
|
||||
void insert(int i, int n, const T &t);
|
||||
void replace(int i, const T &t);
|
||||
void remove(int i);
|
||||
void remove(int i, int n);
|
||||
|
||||
inline T *data() { return ptr; }
|
||||
inline const T *data() const { return ptr; }
|
||||
inline const T * constData() const { return ptr; }
|
||||
typedef int size_type;
|
||||
typedef T value_type;
|
||||
typedef value_type *pointer;
|
||||
typedef const value_type *const_pointer;
|
||||
typedef value_type &reference;
|
||||
typedef const value_type &const_reference;
|
||||
typedef qptrdiff difference_type;
|
||||
|
||||
typedef T* iterator;
|
||||
typedef const T* const_iterator;
|
||||
|
||||
inline iterator begin() { return ptr; }
|
||||
inline const_iterator begin() const { return ptr; }
|
||||
inline const_iterator constBegin() const { return ptr; }
|
||||
inline iterator end() { return ptr + s; }
|
||||
inline const_iterator end() const { return ptr + s; }
|
||||
inline const_iterator constEnd() const { return ptr + s; }
|
||||
iterator insert(iterator before, int n, const T &x);
|
||||
inline iterator insert(iterator before, const T &x) { return insert(before, 1, x); }
|
||||
iterator erase(iterator begin, iterator end);
|
||||
inline iterator erase(iterator pos) { return erase(pos, pos+1); }
|
||||
|
||||
private:
|
||||
void reallocData(int size, int alloc);
|
||||
|
||||
int a; // capacity
|
||||
int s; // size
|
||||
T *ptr; // data
|
||||
};
|
||||
|
||||
template <class T>
|
||||
Q_INLINE_TEMPLATE QVarLengthArray<T>::QVarLengthArray(int asize)
|
||||
: a(asize), s(asize), ptr(nullptr)
|
||||
{
|
||||
if (s <= 0) {
|
||||
return;
|
||||
}
|
||||
ptr = static_cast<T *>(::malloc(s * sizeof(T)));
|
||||
Q_CHECK_PTR(ptr);
|
||||
if (QTypeInfo<T>::isComplex) {
|
||||
T *i = ptr + s;
|
||||
while (i != ptr) {
|
||||
new (--i) T();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template <class T>
|
||||
Q_INLINE_TEMPLATE void QVarLengthArray<T>::resize(int asize)
|
||||
{
|
||||
reallocData(asize, qMax(asize, a));
|
||||
}
|
||||
|
||||
template <class T>
|
||||
Q_INLINE_TEMPLATE void QVarLengthArray<T>::reserve(int asize)
|
||||
{
|
||||
if (asize > a) {
|
||||
reallocData(s, asize);
|
||||
}
|
||||
}
|
||||
|
||||
template <class T>
|
||||
Q_OUTOFLINE_TEMPLATE void QVarLengthArray<T>::append(const T *abuf, int increment)
|
||||
{
|
||||
if (increment <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
Q_ASSERT(abuf);
|
||||
const int asize = s + increment;
|
||||
|
||||
if (asize > a) {
|
||||
reallocData(s, asize);
|
||||
}
|
||||
|
||||
if (QTypeInfo<T>::isComplex) {
|
||||
// call constructor for new objects (which can throw)
|
||||
while (s < asize) {
|
||||
new (ptr+(s++)) T(*abuf++);
|
||||
}
|
||||
} else {
|
||||
::memcpy(&ptr[s], abuf, increment * sizeof(T));
|
||||
s = asize;
|
||||
}
|
||||
}
|
||||
|
||||
template <class T>
|
||||
Q_OUTOFLINE_TEMPLATE void QVarLengthArray<T>::reallocData(int asize, int aalloc)
|
||||
{
|
||||
Q_ASSERT(aalloc >= asize);
|
||||
T *oldPtr = ptr;
|
||||
int osize = s;
|
||||
|
||||
const int copySize = qMin(asize, osize);
|
||||
if (aalloc != a) {
|
||||
ptr = static_cast<T *>(::malloc(aalloc * sizeof(T)));
|
||||
Q_CHECK_PTR(ptr);
|
||||
s = 0;
|
||||
a = aalloc;
|
||||
|
||||
if (QTypeInfo<T>::isStatic) {
|
||||
// copy all the old elements
|
||||
while (s < copySize) {
|
||||
new (ptr+s) T(*(oldPtr+s));
|
||||
(oldPtr+s)->~T();
|
||||
s++;
|
||||
}
|
||||
} else {
|
||||
::memcpy(ptr, oldPtr, copySize * sizeof(T));
|
||||
}
|
||||
}
|
||||
s = copySize;
|
||||
|
||||
if (QTypeInfo<T>::isComplex) {
|
||||
// destroy remaining old objects
|
||||
while (osize > asize) {
|
||||
(oldPtr+(--osize))->~T();
|
||||
}
|
||||
}
|
||||
|
||||
if (oldPtr && oldPtr != ptr) {
|
||||
::free(oldPtr);
|
||||
}
|
||||
|
||||
if (QTypeInfo<T>::isComplex) {
|
||||
// call default constructor for new objects (which can throw)
|
||||
while (s < asize) {
|
||||
new (ptr+(s++)) T;
|
||||
}
|
||||
} else {
|
||||
s = asize;
|
||||
}
|
||||
}
|
||||
|
||||
template <class T>
|
||||
Q_OUTOFLINE_TEMPLATE T QVarLengthArray<T>::value(int i) const
|
||||
{
|
||||
if (i < 0 || i >= size()) {
|
||||
return T();
|
||||
}
|
||||
return at(i);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
Q_OUTOFLINE_TEMPLATE T QVarLengthArray<T>::value(int i, const T &defaultValue) const
|
||||
{
|
||||
return (i < 0 || i >= size()) ? defaultValue : at(i);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline void QVarLengthArray<T>::insert(int i, const T &t)
|
||||
{
|
||||
Q_ASSERT_X(i >= 0 && i <= s, "QVarLengthArray::insert", "index out of range");
|
||||
insert(begin() + i, 1, t);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline void QVarLengthArray<T>::insert(int i, int n, const T &t)
|
||||
{
|
||||
Q_ASSERT_X(i >= 0 && i <= s, "QVarLengthArray::insert", "index out of range");
|
||||
insert(begin() + i, n, t);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline void QVarLengthArray<T>::remove(int i, int n)
|
||||
{
|
||||
Q_ASSERT_X(i >= 0 && n >= 0 && i + n <= s, "QVarLengthArray::remove", "index out of range");
|
||||
erase(begin() + i, begin() + i + n);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline void QVarLengthArray<T>::remove(int i)
|
||||
{
|
||||
Q_ASSERT_X(i >= 0 && i < s, "QVarLengthArray::remove", "index out of range");
|
||||
erase(begin() + i, begin() + i + 1);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline void QVarLengthArray<T>::prepend(const T &t)
|
||||
{
|
||||
insert(begin(), 1, t);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline void QVarLengthArray<T>::replace(int i, const T &t)
|
||||
{
|
||||
Q_ASSERT_X(i >= 0 && i < s, "QVarLengthArray::replace", "index out of range");
|
||||
ptr[i] = t;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
Q_OUTOFLINE_TEMPLATE typename QVarLengthArray<T>::iterator QVarLengthArray<T>::insert(iterator before, size_type n, const T &t)
|
||||
{
|
||||
int offset = int(before - ptr);
|
||||
if (n != 0) {
|
||||
resize(s + n);
|
||||
if (QTypeInfo<T>::isStatic) {
|
||||
T *b = ptr + offset;
|
||||
T *j = ptr + s;
|
||||
T *i = j - n;
|
||||
while (i != b) {
|
||||
*--j = *--i;
|
||||
}
|
||||
i = b + n;
|
||||
while (i != b) {
|
||||
*--i = t;
|
||||
}
|
||||
} else {
|
||||
T *b = ptr + offset;
|
||||
T *i = b + n;
|
||||
::memmove(i, b, (s - offset - n) * sizeof(T));
|
||||
while (i != b) {
|
||||
new (--i) T(t);
|
||||
}
|
||||
}
|
||||
}
|
||||
return ptr + offset;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
Q_OUTOFLINE_TEMPLATE typename QVarLengthArray<T>::iterator QVarLengthArray<T>::erase(iterator abegin, iterator aend)
|
||||
{
|
||||
int f = int(abegin - ptr);
|
||||
int l = int(aend - ptr);
|
||||
int n = l - f;
|
||||
if (QTypeInfo<T>::isComplex) {
|
||||
qCopy(ptr + l, ptr + s, ptr + f);
|
||||
T *i = ptr + s;
|
||||
T *b = ptr + s - n;
|
||||
while (i != b) {
|
||||
--i;
|
||||
i->~T();
|
||||
}
|
||||
} else {
|
||||
::memmove(ptr + f, ptr + l, (s - l) * sizeof(T));
|
||||
}
|
||||
s -= n;
|
||||
return ptr + f;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
bool operator==(const QVarLengthArray<T> &l, const QVarLengthArray<T> &r)
|
||||
{
|
||||
if (l.size() != r.size()) {
|
||||
return false;
|
||||
}
|
||||
for (int i = 0; i < l.size(); i++) {
|
||||
if (l.at(i) != r.at(i)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
bool operator!=(const QVarLengthArray<T> &l, const QVarLengthArray<T> &r)
|
||||
{
|
||||
return !(l == r);
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // QVARLENGTHARRAY_H
|
|
@ -1,540 +0,0 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2015 The Qt Company Ltd.
|
||||
** Copyright (C) 2016 Ivailo Monev
|
||||
**
|
||||
** This file is part of the documentation of the Katie Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:FDL$
|
||||
** GNU Free Documentation License Usage
|
||||
** This file may be used under the terms of the GNU Free
|
||||
** Documentation License version 1.3 as published by the Free Software
|
||||
** Foundation and appearing in the file included in the packaging of
|
||||
** this file. Please review the following information to ensure
|
||||
** the GNU Free Documentation License version 1.3 requirements
|
||||
** will be met: http://www.gnu.org/copyleft/fdl.html.
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
/*!
|
||||
\class QVarLengthArray
|
||||
\brief The QVarLengthArray class provides a low-level variable-length array.
|
||||
|
||||
\ingroup tools
|
||||
\reentrant
|
||||
|
||||
The C++ language doesn't support variable-length arrays on the stack.
|
||||
For example, the following code won't compile:
|
||||
|
||||
\snippet doc/src/snippets/code/doc_src_qvarlengtharray.cpp 0
|
||||
|
||||
The alternative is to allocate the array on the heap (with
|
||||
\c{new}):
|
||||
|
||||
\snippet doc/src/snippets/code/doc_src_qvarlengtharray.cpp 1
|
||||
|
||||
However, if myfunc() is called very frequently from the
|
||||
application's inner loop, heap allocation can be a major source
|
||||
of slowdown.
|
||||
|
||||
QVarLengthArray does not attempt to work around this gap in the
|
||||
C++ language. It allocates elements on the heap, however the
|
||||
option to reserve elements is there.
|
||||
|
||||
QVarLengthArray's value type must be an \l{assignable data type}.
|
||||
This covers most data types that are commonly used, but the
|
||||
compiler won't let you, for example, store a QWidget as a value;
|
||||
instead, store a QWidget *.
|
||||
|
||||
QVarLengthArray, like QVector, provides a resizable array data
|
||||
structure. The main differences between the two classes are:
|
||||
|
||||
\list
|
||||
\o QVarLengthArray's API is much more low-level. It provides no
|
||||
iterators and lacks much of QVector's functionality.
|
||||
|
||||
\o QVarLengthArray doesn't initialize the memory if the value is
|
||||
a basic type. (QVector always does.)
|
||||
|
||||
\o QVector uses \l{implicit sharing} as a memory optimization.
|
||||
QVarLengthArray doesn't provide that feature; however, it
|
||||
usually produces slightly better performance due to reduced
|
||||
overhead, especially in tight loops.
|
||||
\endlist
|
||||
|
||||
In summary, QVarLengthArray is a low-level optimization class
|
||||
that only makes sense in very specific cases. It is used a few
|
||||
places inside Qt and was added to Qt's public API for the
|
||||
convenience of advanced users.
|
||||
|
||||
\sa QVector, QList
|
||||
*/
|
||||
|
||||
/*! \fn QVarLengthArray::QVarLengthArray(int size)
|
||||
|
||||
Constructs an array with an initial size of \a size elements.
|
||||
|
||||
If the value type is a primitive type (e.g., char, int, float) or
|
||||
a pointer type (e.g., QWidget *), the elements are not
|
||||
initialized. For other types, the elements are initialized with a
|
||||
\l{default-constructed value}.
|
||||
*/
|
||||
|
||||
/*! \fn QVarLengthArray::~QVarLengthArray()
|
||||
|
||||
Destroys the array.
|
||||
*/
|
||||
|
||||
/*! \fn int QVarLengthArray::size() const
|
||||
|
||||
Returns the number of elements in the array.
|
||||
|
||||
\sa isEmpty(), resize()
|
||||
*/
|
||||
|
||||
/*! \fn int QVarLengthArray::count() const
|
||||
|
||||
Same as size().
|
||||
|
||||
\sa isEmpty(), resize()
|
||||
*/
|
||||
|
||||
/*! \fn bool QVarLengthArray::isEmpty() const
|
||||
|
||||
Returns true if the array has size 0; otherwise returns false.
|
||||
|
||||
\sa size(), resize()
|
||||
*/
|
||||
|
||||
/*! \fn void QVarLengthArray::clear()
|
||||
|
||||
Removes all the elements from the array.
|
||||
|
||||
Same as resize(0).
|
||||
*/
|
||||
|
||||
/*! \fn void QVarLengthArray::resize(int size)
|
||||
|
||||
Sets the size of the array to \a size. If \a size is greater than
|
||||
the current size, elements are added to the end. If \a size is
|
||||
less than the current size, elements are removed from the end.
|
||||
|
||||
If the value type is a primitive type (e.g., char, int, float) or
|
||||
a pointer type (e.g., QWidget *), new elements are not
|
||||
initialized. For other types, the elements are initialized with a
|
||||
\l{default-constructed value}.
|
||||
|
||||
\sa size()
|
||||
*/
|
||||
|
||||
/*! \fn int QVarLengthArray::capacity() const
|
||||
|
||||
Returns the maximum number of elements that can be stored in the
|
||||
array without forcing a reallocation.
|
||||
|
||||
The sole purpose of this function is to provide a means of fine
|
||||
tuning QVarLengthArray's memory usage. In general, you will rarely ever
|
||||
need to call this function. If you want to know how many items are
|
||||
in the array, call size().
|
||||
|
||||
\sa reserve()
|
||||
*/
|
||||
|
||||
/*! \fn void QVarLengthArray::reserve(int size)
|
||||
|
||||
Attempts to allocate memory for at least \a size elements. If you
|
||||
know in advance how large the array can get, you can call this
|
||||
function and if you call resize() often, you are likely to get
|
||||
better performance. If \a size is an underestimate, the worst
|
||||
that will happen is that the QVarLengthArray will be a bit
|
||||
slower.
|
||||
|
||||
The sole purpose of this function is to provide a means of fine
|
||||
tuning QVarLengthArray's memory usage. In general, you will
|
||||
rarely ever need to call this function. If you want to change the
|
||||
size of the array, call resize().
|
||||
|
||||
\sa capacity()
|
||||
*/
|
||||
|
||||
/*! \fn T &QVarLengthArray::operator[](int i)
|
||||
|
||||
Returns a reference to the item at index position \a i.
|
||||
|
||||
\a i must be a valid index position in the array (i.e., 0 <= \a i
|
||||
< size()).
|
||||
|
||||
\sa data(), at()
|
||||
*/
|
||||
|
||||
/*! \fn const T &QVarLengthArray::operator[](int i) const
|
||||
|
||||
\overload
|
||||
*/
|
||||
|
||||
|
||||
/*!
|
||||
\fn void QVarLengthArray::append(const T &t)
|
||||
|
||||
Appends item \a t to the array, extending the array if necessary.
|
||||
|
||||
\sa removeLast()
|
||||
*/
|
||||
|
||||
|
||||
/*!
|
||||
\fn inline void QVarLengthArray::removeLast()
|
||||
\since 4.5
|
||||
|
||||
Decreases the size of the array by one. The allocated size is not changed.
|
||||
|
||||
\sa append()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn void QVarLengthArray::append(const T *buf, int size)
|
||||
|
||||
Appends \a size amount of items referenced by \a buf to this array.
|
||||
*/
|
||||
|
||||
|
||||
/*! \fn T *QVarLengthArray::data()
|
||||
|
||||
Returns a pointer to the data stored in the array. The pointer can
|
||||
be used to access and modify the items in the array.
|
||||
|
||||
Example:
|
||||
\snippet doc/src/snippets/code/doc_src_qvarlengtharray.cpp 3
|
||||
|
||||
The pointer remains valid as long as the array isn't reallocated.
|
||||
|
||||
This function is mostly useful to pass an array to a function
|
||||
that accepts a plain C++ array.
|
||||
|
||||
\sa constData(), operator[]()
|
||||
*/
|
||||
|
||||
/*! \fn const T *QVarLengthArray::data() const
|
||||
|
||||
\overload
|
||||
*/
|
||||
|
||||
/*! \fn const T *QVarLengthArray::constData() const
|
||||
|
||||
Returns a const pointer to the data stored in the array. The
|
||||
pointer can be used to access the items in the array. The
|
||||
pointer remains valid as long as the array isn't reallocated.
|
||||
|
||||
This function is mostly useful to pass an array to a function
|
||||
that accepts a plain C++ array.
|
||||
|
||||
\sa data(), operator[]()
|
||||
*/
|
||||
|
||||
/*! \fn QVarLengthArray<T> &QVarLengthArray::operator=(const QVarLengthArray<T> &other)
|
||||
Assigns \a other to this array and returns a reference to this array.
|
||||
*/
|
||||
|
||||
/*! \fn QVarLengthArray::QVarLengthArray(const QVarLengthArray<T> &other)
|
||||
Constructs a copy of \a other.
|
||||
*/
|
||||
|
||||
/*! \fn const T &QVarLengthArray::at(int i) const
|
||||
|
||||
Returns a reference to the item at index position \a i.
|
||||
|
||||
\a i must be a valid index position in the array (i.e., 0 <= \a i
|
||||
< size()).
|
||||
|
||||
\sa value(), operator[]()
|
||||
*/
|
||||
|
||||
/*! \fn T QVarLengthArray::value(int i) const
|
||||
|
||||
Returns the value at index position \a i.
|
||||
|
||||
If the index \a i is out of bounds, the function returns
|
||||
a \l{default-constructed value}. If you are certain that
|
||||
\a i is within bounds, you can use at() instead, which is slightly
|
||||
faster.
|
||||
|
||||
\sa at(), operator[]()
|
||||
*/
|
||||
|
||||
/*! \fn T QVarLengthArray::value(int i, const T &defaultValue) const
|
||||
|
||||
\overload
|
||||
|
||||
If the index \a i is out of bounds, the function returns
|
||||
\a defaultValue.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\typedef QVarLengthArray::size_type
|
||||
\since 4.7
|
||||
|
||||
Typedef for int. Provided for STL compatibility.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\typedef QVarLengthArray::value_type
|
||||
\since 4.7
|
||||
|
||||
Typedef for T. Provided for STL compatibility.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\typedef QVarLengthArray::difference_type
|
||||
\since 4.7
|
||||
|
||||
Typedef for ptrdiff_t. Provided for STL compatibility.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\typedef QVarLengthArray::pointer
|
||||
\since 4.7
|
||||
|
||||
Typedef for T *. Provided for STL compatibility.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\typedef QVarLengthArray::const_pointer
|
||||
\since 4.7
|
||||
|
||||
Typedef for const T *. Provided for STL compatibility.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\typedef QVarLengthArray::reference
|
||||
\since 4.7
|
||||
|
||||
Typedef for T &. Provided for STL compatibility.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\typedef QVarLengthArray::const_reference
|
||||
\since 4.7
|
||||
|
||||
Typedef for const T &. Provided for STL compatibility.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\typedef QVarLengthArray::const_iterator
|
||||
\since 4.7
|
||||
|
||||
Typedef for const T *. Provided for STL compatibility.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\typedef QVarLengthArray::iterator
|
||||
\since 4.7
|
||||
|
||||
Typedef for T *. Provided for STL compatibility.
|
||||
*/
|
||||
|
||||
/*! \fn void QVarLengthArray::prepend(const T &value)
|
||||
|
||||
\since 4.8
|
||||
Inserts \a value at the beginning of the array.
|
||||
|
||||
|
||||
This is the same as vector.insert(0, \a value).
|
||||
|
||||
For large arrays, this operation can be slow (\l{linear time}),
|
||||
because it requires moving all the items in the vector by one
|
||||
position further in memory. If you want a container class that
|
||||
provides a fast prepend() function, use QList instead.
|
||||
|
||||
\sa append(), insert()
|
||||
*/
|
||||
|
||||
/*! \fn void QVarLengthArray::replace(int i, const T &value)
|
||||
|
||||
\since 4.8
|
||||
Replaces the item at index position \a i with \a value.
|
||||
|
||||
\a i must be a valid index position in the array (i.e., 0 <= \a
|
||||
i < size()).
|
||||
|
||||
\sa operator[](), remove()
|
||||
*/
|
||||
|
||||
/*! \fn void QVarLengthArray::remove(int i)
|
||||
|
||||
\overload
|
||||
\since 4.8
|
||||
|
||||
Removes the element at index position \a i.
|
||||
|
||||
\sa insert(), replace()
|
||||
*/
|
||||
|
||||
/*! \fn void QVarLengthArray::remove(int i, int count)
|
||||
|
||||
\overload
|
||||
\since 4.8
|
||||
|
||||
Removes \a count elements from the middle of the array, starting at
|
||||
index position \a i.
|
||||
|
||||
\sa insert(), replace()
|
||||
*/
|
||||
|
||||
/*! \fn QVarLengthArray::iterator QVarLengthArray::begin()
|
||||
\since 4.8
|
||||
|
||||
Returns an \l{STL-style iterator} pointing to the first item in
|
||||
the array.
|
||||
|
||||
\sa constBegin(), end()
|
||||
*/
|
||||
|
||||
/*! \fn QVarLengthArray::const_iterator QVarLengthArray::begin() const
|
||||
\since 4.8
|
||||
\overload
|
||||
*/
|
||||
|
||||
/*! \fn QVarLengthArray::const_iterator QVarLengthArray::constBegin() const
|
||||
\since 4.8
|
||||
|
||||
Returns a const \l{STL-style iterator} pointing to the first item
|
||||
in the array.
|
||||
|
||||
\sa begin(), constEnd()
|
||||
*/
|
||||
|
||||
/*! \fn QVarLengthArray::iterator QVarLengthArray::end()
|
||||
\since 4.8
|
||||
|
||||
Returns an \l{STL-style iterator} pointing to the imaginary item
|
||||
after the last item in the array.
|
||||
|
||||
\sa begin(), constEnd()
|
||||
*/
|
||||
|
||||
/*! \fn QVarLengthArray::const_iterator QVarLengthArray::end() const
|
||||
\since 4.8
|
||||
|
||||
\overload
|
||||
*/
|
||||
|
||||
/*! \fn QVarLengthArray::const_iterator QVarLengthArray::constEnd() const
|
||||
\since 4.8
|
||||
|
||||
Returns a const \l{STL-style iterator} pointing to the imaginary
|
||||
item after the last item in the array.
|
||||
|
||||
\sa constBegin(), end()
|
||||
*/
|
||||
|
||||
/*! \fn QVarLengthArray::iterator QVarLengthArray::erase(iterator pos)
|
||||
\since 4.8
|
||||
|
||||
Removes the item pointed to by the iterator \a pos from the
|
||||
vector, and returns an iterator to the next item in the vector
|
||||
(which may be end()).
|
||||
|
||||
\sa insert(), remove()
|
||||
*/
|
||||
|
||||
/*! \fn QVarLengthArray::iterator QVarLengthArray::erase(iterator begin, iterator end)
|
||||
|
||||
\overload
|
||||
\since 4.8
|
||||
|
||||
Removes all the items from \a begin up to (but not including) \a
|
||||
end. Returns an iterator to the same item that \a end referred to
|
||||
before the call.
|
||||
*/
|
||||
|
||||
/*! \fn void QVarLengthArray::insert(int i, const T &value)
|
||||
\since 4.8
|
||||
|
||||
Inserts \a value at index position \a i in the array. If \a i is
|
||||
0, the value is prepended to the vector. If \a i is size(), the
|
||||
value is appended to the vector.
|
||||
|
||||
For large arrays, this operation can be slow (\l{linear time}),
|
||||
because it requires moving all the items at indexes \a i and
|
||||
above by one position further in memory.
|
||||
|
||||
\sa remove()
|
||||
*/
|
||||
|
||||
/*! \fn void QVarLengthArray::insert(int i, int count, const T &value)
|
||||
|
||||
\overload
|
||||
\since 4.8
|
||||
|
||||
Inserts \a count copies of \a value at index position \a i in the
|
||||
vector.
|
||||
*/
|
||||
|
||||
/*! \fn QVarLengthArray::iterator QVarLengthArray::insert(iterator before, const T &value)
|
||||
|
||||
\overload
|
||||
\since 4.8
|
||||
|
||||
Inserts \a value in front of the item pointed to by the iterator
|
||||
\a before. Returns an iterator pointing at the inserted item.
|
||||
*/
|
||||
|
||||
/*! \fn QVarLengthArray::iterator QVarLengthArray::insert(iterator before, int count, const T &value)
|
||||
|
||||
\since 4.8
|
||||
Inserts \a count copies of \a value in front of the item pointed to
|
||||
by the iterator \a before. Returns an iterator pointing at the
|
||||
first of the inserted items.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/*! \fn bool operator==(const QVarLengthArray<T> &left, const QVarLengthArray<T> &right)
|
||||
|
||||
\relates QVarLengthArray
|
||||
\since 4.8
|
||||
Returns true if the two arrays, specified by \a left and \a right, are equal.
|
||||
|
||||
Two arrays are considered equal if they contain the same values
|
||||
in the same order.
|
||||
|
||||
This function requires the value type to have an implementation
|
||||
of \c operator==().
|
||||
|
||||
\sa operator!=()
|
||||
*/
|
||||
|
||||
/*! \fn bool operator!=(const QVarLengthArray<T> &left, const QVarLengthArray<T> &right)
|
||||
|
||||
\relates QVarLengthArray
|
||||
\since 4.8
|
||||
Returns true if the two arrays, specified by \a left and \a right, are \e not equal.
|
||||
|
||||
Two arrays are considered equal if they contain the same values
|
||||
in the same order.
|
||||
|
||||
This function requires the value type to have an implementation
|
||||
of \c operator==().
|
||||
|
||||
\sa operator==()
|
||||
*/
|
||||
|
||||
/*! \fn QVarLengthArray &QVarLengthArray::operator<<(const T &value)
|
||||
|
||||
\since 4.8
|
||||
Appends \a value to the array and returns a reference to this
|
||||
vector.
|
||||
|
||||
\sa append(), operator+=()
|
||||
*/
|
||||
|
||||
/*! \fn QVarLengthArray &QVarLengthArray::operator+=(const T &value)
|
||||
|
||||
\since 4.8
|
||||
Appends \a value to the array and returns a reference to this
|
||||
vector.
|
||||
|
||||
\sa append(), operator<<()
|
||||
*/
|
||||
|
|
@ -89,7 +89,7 @@ int QVectorData::grow(int sizeofTypedData, int size, int sizeofT, bool excessive
|
|||
stores its items in adjacent memory locations and provides fast
|
||||
index-based access.
|
||||
|
||||
QList\<T\> and QVarLengthArray\<T\> provide similar functionality.
|
||||
QList\<T\> provides similar functionality.
|
||||
Here's an overview:
|
||||
|
||||
\list
|
||||
|
@ -102,8 +102,6 @@ int QVectorData::grow(int sizeofTypedData, int size, int sizeofT, bool excessive
|
|||
if your items are larger than a pointer and you want to avoid
|
||||
the overhead of allocating them on the heap individually at
|
||||
insertion time, then use QVector.
|
||||
\i If you want a low-level variable-size array, QVarLengthArray
|
||||
may be sufficient.
|
||||
\endlist
|
||||
|
||||
Here's an example of a QVector that stores integers and a QVector
|
||||
|
@ -197,10 +195,6 @@ int QVectorData::grow(int sizeofTypedData, int size, int sizeofT, bool excessive
|
|||
QVector::iterator). In practice, these are rarely used, because
|
||||
you can use indexes into the QVector.
|
||||
|
||||
In addition to QVector, Qt also provides QVarLengthArray, a very
|
||||
low-level class with little functionality that is optimized for
|
||||
speed.
|
||||
|
||||
QVector does \e not support inserting, prepending, appending or replacing
|
||||
with references to its own values. Doing so will cause your application to
|
||||
abort with an error message.
|
||||
|
|
|
@ -27,7 +27,6 @@
|
|||
#include "qstringlist.h"
|
||||
#include "qtimer.h"
|
||||
#include "qthread.h"
|
||||
|
||||
#include "qdbusargument.h"
|
||||
#include "qdbusconnection_p.h"
|
||||
#include "qdbusconnectionmanager_p.h"
|
||||
|
@ -42,7 +41,6 @@
|
|||
#include "qdbuscontext_p.h"
|
||||
#include "qdbuspendingcall_p.h"
|
||||
#include "qdbusintegrator_p.h"
|
||||
|
||||
#include "qdbusthreaddebug_p.h"
|
||||
|
||||
|
||||
|
@ -113,7 +111,7 @@ Q_AUTOTEST_EXPORT qdbusThreadDebugFunc qdbusThreadDebug = 0;
|
|||
#endif
|
||||
|
||||
typedef void (*QDBusSpyHook)(const QDBusMessage&);
|
||||
typedef QVarLengthArray<QDBusSpyHook> QDBusSpyHookList;
|
||||
typedef QStdVector<QDBusSpyHook> QDBusSpyHookList;
|
||||
Q_GLOBAL_STATIC(QDBusSpyHookList, qDBusSpyHookList)
|
||||
|
||||
extern "C" {
|
||||
|
@ -851,7 +849,7 @@ void QDBusConnectionPrivate::deliverCall(QObject *object, const QDBusMessage &ms
|
|||
"QDBusConnection: internal threading error",
|
||||
"function called for an object that is in another thread!!");
|
||||
|
||||
QVarLengthArray<void *> params;
|
||||
QStdVector<void *> params;
|
||||
params.reserve(metaTypes.count());
|
||||
|
||||
QVariantList auxParameters;
|
||||
|
|
|
@ -20,20 +20,17 @@
|
|||
****************************************************************************/
|
||||
|
||||
#include "qdbusmetaobject_p.h"
|
||||
|
||||
#include <QtCore/qbytearray.h>
|
||||
#include <QtCore/qhash.h>
|
||||
#include <QtCore/qstring.h>
|
||||
#include <QtCore/qvarlengtharray.h>
|
||||
|
||||
#include "qbytearray.h"
|
||||
#include "qhash.h"
|
||||
#include "qstring.h"
|
||||
#include "qdbusutil_p.h"
|
||||
#include "qdbuserror.h"
|
||||
#include "qdbusmetatype.h"
|
||||
#include "qdbusargument.h"
|
||||
#include "qdbusintrospection_p.h"
|
||||
#include "qdbusabstractinterface_p.h"
|
||||
|
||||
#include "qmetaobject_p.h"
|
||||
#include "qstdcontainers_p.h"
|
||||
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
@ -56,8 +53,8 @@ private:
|
|||
QByteArray name;
|
||||
QByteArray inputSignature;
|
||||
QByteArray outputSignature;
|
||||
QVarLengthArray<int> inputTypes;
|
||||
QVarLengthArray<int> outputTypes;
|
||||
QStdVector<int> inputTypes;
|
||||
QStdVector<int> outputTypes;
|
||||
int flags;
|
||||
};
|
||||
|
||||
|
@ -355,7 +352,7 @@ void QDBusMetaObjectGenerator::write(QDBusMetaObject *obj)
|
|||
foreach (const Method &mm, methods)
|
||||
data_size += 2 + mm.inputTypes.count() + mm.outputTypes.count();
|
||||
|
||||
QVarLengthArray<int> idata(data_size + 1);
|
||||
QStdVector<int> idata(data_size + 1);
|
||||
|
||||
QDBusMetaObjectPrivate *header = reinterpret_cast<QDBusMetaObjectPrivate *>(idata.data());
|
||||
header->revision = qmetaobjectrevision;
|
||||
|
|
|
@ -332,7 +332,7 @@ protected:
|
|||
/.
|
||||
|
||||
#include "qdeclarativejsparser_p.h"
|
||||
#include <QVarLengthArray>
|
||||
#include "qstdcontainers_p.h"
|
||||
|
||||
//
|
||||
// This file is automatically generated from qdeclarativejs.g.
|
||||
|
@ -396,8 +396,8 @@ static inline AST::SourceLocation location(Lexer *lexer)
|
|||
|
||||
AST::UiQualifiedId *Parser::reparseAsQualifiedId(AST::ExpressionNode *expr)
|
||||
{
|
||||
QVarLengthArray<NameId *> nameIds;
|
||||
QVarLengthArray<AST::SourceLocation> locations;
|
||||
QStdVector<NameId *> nameIds;
|
||||
QStdVector<AST::SourceLocation> locations;
|
||||
|
||||
AST::ExpressionNode *it = expr;
|
||||
while (AST::FieldMemberExpression *m = AST::cast<AST::FieldMemberExpression *>(it)) {
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
#include "qdeclarativejsast_p.h"
|
||||
#include "qdeclarativejsnodepool_p.h"
|
||||
#include "qdeclarativejsparser_p.h"
|
||||
#include <QVarLengthArray>
|
||||
#include "qstdcontainers_p.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
|
@ -93,8 +93,8 @@ static inline AST::SourceLocation location(Lexer *lexer)
|
|||
|
||||
AST::UiQualifiedId *Parser::reparseAsQualifiedId(AST::ExpressionNode *expr)
|
||||
{
|
||||
QVarLengthArray<NameId *> nameIds;
|
||||
QVarLengthArray<AST::SourceLocation> locations;
|
||||
QStdVector<NameId *> nameIds;
|
||||
QStdVector<AST::SourceLocation> locations;
|
||||
|
||||
AST::ExpressionNode *it = expr;
|
||||
while (AST::FieldMemberExpression *m = AST::cast<AST::FieldMemberExpression *>(it)) {
|
||||
|
|
|
@ -116,7 +116,7 @@ void QDeclarativeBoundSignal::disconnect()
|
|||
{
|
||||
QMetaObject::disconnect(m_scope, m_signal.methodIndex(), this, evaluateIdx);
|
||||
QObjectPrivate * const priv = QObjectPrivate::get(m_scope);
|
||||
QVarLengthArray<char> signalSignature;
|
||||
QStdVector<char> signalSignature;
|
||||
QObjectPrivate::signalSignature(m_signal, &signalSignature);
|
||||
priv->disconnectNotify(signalSignature.constData());
|
||||
}
|
||||
|
|
|
@ -197,7 +197,7 @@ void QDeclarativeNotifierEndpoint::disconnect()
|
|||
QMetaObject::disconnectOne(s->source, s->sourceSignal, target, targetMethod);
|
||||
QObjectPrivate * const priv = QObjectPrivate::get(s->source);
|
||||
const QMetaMethod signal = s->source->metaObject()->method(s->sourceSignal);
|
||||
QVarLengthArray<char> signalSignature;
|
||||
QStdVector<char> signalSignature;
|
||||
QObjectPrivate::signalSignature(signal, &signalSignature);
|
||||
priv->disconnectNotify(signalSignature.constData());
|
||||
s->source = 0;
|
||||
|
|
|
@ -29,9 +29,9 @@
|
|||
#include "qdeclarativeguard_p.h"
|
||||
#include "qdeclarativevmemetaobject_p.h"
|
||||
#include "qdeclarativecommon_p.h"
|
||||
#include <QtCore/qtimer.h>
|
||||
#include <QtCore/qvarlengtharray.h>
|
||||
#include <QtScript/qscriptcontextinfo.h>
|
||||
#include "qtimer.h"
|
||||
#include "qscriptcontextinfo.h"
|
||||
#include "qstdcontainers_p.h"
|
||||
|
||||
#include <limits.h>
|
||||
|
||||
|
@ -898,7 +898,7 @@ QDeclarativeObjectMethodScriptClass::callPrecise(QObject *object, const QDeclara
|
|||
|
||||
QMetaMethod m = object->metaObject()->method(data.coreIndex);
|
||||
QList<QByteArray> argTypeNames = m.parameterTypes();
|
||||
QVarLengthArray<int> argTypes(argTypeNames.count());
|
||||
QStdVector<int> argTypes(argTypeNames.count());
|
||||
|
||||
// ### Cache
|
||||
for (int ii = 0; ii < argTypeNames.count(); ++ii) {
|
||||
|
@ -928,13 +928,13 @@ QDeclarativeObjectMethodScriptClass::callMethod(QObject *object, int index,
|
|||
{
|
||||
if (argCount > 0) {
|
||||
|
||||
QVarLengthArray<MetaCallArgument> args(argCount + 1);
|
||||
QStdVector<MetaCallArgument> args(argCount + 1);
|
||||
args[0].initAsType(returnType, engine);
|
||||
|
||||
for (int ii = 0; ii < argCount; ++ii)
|
||||
args[ii + 1].fromScriptValue(argTypes[ii], engine, ctxt->argument(ii));
|
||||
|
||||
QVarLengthArray<void *> argData(args.count());
|
||||
QStdVector<void *> argData(args.count());
|
||||
for (int ii = 0; ii < args.count(); ++ii)
|
||||
argData[ii] = args[ii].dataPtr();
|
||||
|
||||
|
@ -1003,7 +1003,7 @@ QDeclarativeObjectMethodScriptClass::callOverloaded(MethodData *method, QScriptC
|
|||
continue; // We already have a better option
|
||||
|
||||
int methodMatchScore = 0;
|
||||
QVarLengthArray<int> methodArgTypes(methodArgumentCount);
|
||||
QStdVector<int> methodArgTypes(methodArgumentCount);
|
||||
|
||||
bool unknownArgument = false;
|
||||
for (int ii = 0; ii < methodArgumentCount; ++ii) {
|
||||
|
|
|
@ -1596,7 +1596,7 @@ bool QDeclarativePropertyPrivate::connect(QObject *sender, int signal_index,
|
|||
// would return the wrong result inside connectNotify().
|
||||
const QMetaMethod signal = sender->metaObject()->method(signal_index);
|
||||
QObjectPrivate * const senderPriv = QObjectPrivate::get(sender);
|
||||
QVarLengthArray<char> signalSignature;
|
||||
QStdVector<char> signalSignature;
|
||||
QObjectPrivate::signalSignature(signal, &signalSignature);
|
||||
senderPriv->connectNotify(signalSignature.constData());
|
||||
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
****************************************************************************/
|
||||
|
||||
#include "qdeclarativevme_p.h"
|
||||
|
||||
#include "qdeclarativecompiler_p.h"
|
||||
#include "qdeclarativeboundsignal_p.h"
|
||||
#include "qdeclarativestringconverters_p.h"
|
||||
|
@ -40,26 +39,25 @@
|
|||
#include "qdeclarativecompiledbindings_p.h"
|
||||
#include "qdeclarativeglobal_p.h"
|
||||
#include "qdeclarativescriptstring.h"
|
||||
|
||||
#include <QStack>
|
||||
#include <QWidget>
|
||||
#include <QColor>
|
||||
#include <QPoint>
|
||||
#include <QSize>
|
||||
#include <QRect>
|
||||
#include <QtCore/qdebug.h>
|
||||
#include <QtCore/qvarlengtharray.h>
|
||||
#include <QtCore/qcoreapplication.h>
|
||||
#include <QtCore/qdatetime.h>
|
||||
#include "qstack.h"
|
||||
#include "qwidget.h"
|
||||
#include "qcolor.h"
|
||||
#include "qpoint.h"
|
||||
#include "qsize.h"
|
||||
#include "qrect.h"
|
||||
#include "qdebug.h"
|
||||
#include "qcoreapplication.h"
|
||||
#include "qdatetime.h"
|
||||
#include "qstdcontainers_p.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
// A simple stack wrapper around QVarLengthArray
|
||||
// A simple stack wrapper around QStdVector
|
||||
template<typename T>
|
||||
class QDeclarativeVMEStack : private QVarLengthArray<T>
|
||||
class QDeclarativeVMEStack : private QStdVector<T>
|
||||
{
|
||||
private:
|
||||
typedef QVarLengthArray<T> VLA;
|
||||
typedef QStdVector<T> VLA;
|
||||
int _index;
|
||||
|
||||
public:
|
||||
|
|
|
@ -37,8 +37,8 @@
|
|||
#include "qpushbutton.h"
|
||||
#include "qset.h"
|
||||
#include "qstyle.h"
|
||||
#include "qvarlengtharray.h"
|
||||
#include "qdialog_p.h"
|
||||
#include "qstdcontainers_p.h"
|
||||
#include "qdebug.h"
|
||||
|
||||
#include <string.h> // for memset()
|
||||
|
@ -1303,7 +1303,7 @@ void QWizardPrivate::updateButtonTexts()
|
|||
void QWizardPrivate::updateButtonLayout()
|
||||
{
|
||||
if (buttonsHaveCustomLayout) {
|
||||
QVarLengthArray<QWizard::WizardButton> array(buttonsCustomLayout.count());
|
||||
QStdVector<QWizard::WizardButton> array(buttonsCustomLayout.count());
|
||||
for (int i = 0; i < buttonsCustomLayout.count(); ++i)
|
||||
array[i] = buttonsCustomLayout.at(i);
|
||||
setButtonLayout(array.constData(), array.count());
|
||||
|
@ -1313,7 +1313,7 @@ void QWizardPrivate::updateButtonLayout()
|
|||
|
||||
const int ArraySize = 12;
|
||||
QWizard::WizardButton array[ArraySize];
|
||||
memset(array, QWizard::NoButton, sizeof(array));
|
||||
::memset(array, QWizard::NoButton, sizeof(array));
|
||||
Q_ASSERT(array[0] == QWizard::NoButton);
|
||||
|
||||
if (opts & QWizard::HaveHelpButton) {
|
||||
|
|
|
@ -27,9 +27,9 @@
|
|||
#include "qgridlayoutengine_p.h"
|
||||
#include "qstyleoption.h"
|
||||
#include "qgraphicswidget_p.h"
|
||||
#include "qvarlengtharray.h"
|
||||
#include "qdebug.h"
|
||||
#include "qmath.h"
|
||||
#include "qstdcontainers_p.h"
|
||||
#include "qcorecommon_p.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
@ -156,9 +156,9 @@ void QGridLayoutRowData::distributeMultiCells(const QGridLayoutRowInfo &rowInfo)
|
|||
int stretch = i.value().q_stretch;
|
||||
|
||||
QGridLayoutBox totalBox = this->totalBox(start, end);
|
||||
QVarLengthArray<QGridLayoutBox> extras(span);
|
||||
QVarLengthArray<qreal> dummy(span);
|
||||
QVarLengthArray<qreal> newSizes(span);
|
||||
QStdVector<QGridLayoutBox> extras(span);
|
||||
QStdVector<qreal> dummy(span);
|
||||
QStdVector<qreal> newSizes(span);
|
||||
|
||||
for (int j = 0; j < NSizes; ++j) {
|
||||
qreal extra = compare(box, totalBox, j);
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
#include "qhash.h"
|
||||
#include "qpaintengine_raster_p.h"
|
||||
#include "qimage_p.h"
|
||||
#include "qvarlengtharray.h"
|
||||
#include "qstdcontainers_p.h"
|
||||
#include "qcorecommon_p.h"
|
||||
#include "qguicommon_p.h"
|
||||
#include "qx11info_x11.h"
|
||||
|
@ -1706,7 +1706,7 @@ static void dither_to_Mono(QImageData *dst, const QImageData *src,
|
|||
|
||||
switch (dithermode) {
|
||||
case Diffuse: {
|
||||
QVarLengthArray<int> lineBuffer(src->width * 2);
|
||||
QStdVector<int> lineBuffer(src->width * 2);
|
||||
int *line1 = lineBuffer.data();
|
||||
int *line2 = lineBuffer.data() + src->width;
|
||||
int bmwidth = (src->width+7)/8;
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
#include "qlist.h"
|
||||
#include "qsizepolicy.h"
|
||||
#include "qvector.h"
|
||||
#include "qvarlengtharray.h"
|
||||
#include "qlayoutengine_p.h"
|
||||
#include "qlayout_p.h"
|
||||
|
||||
|
@ -678,7 +677,7 @@ void QGridLayoutPrivate::setupLayoutData(int hSpacing, int vSpacing)
|
|||
Grid of items. We use it to determine which items are
|
||||
adjacent to which and compute the spacings correctly.
|
||||
*/
|
||||
QVarLengthArray<QGridBox *> grid(rr * cc);
|
||||
QVector<QGridBox *> grid(rr * cc);
|
||||
::memset(grid.data(), 0, size_t(rr) * cc * sizeof(QGridBox *));
|
||||
|
||||
/*
|
||||
|
|
|
@ -23,7 +23,6 @@
|
|||
#include "qplatformdefs.h"
|
||||
#include "qbackingstore_p.h"
|
||||
#include "qdebug.h"
|
||||
#include "qvarlengtharray.h"
|
||||
#include "qevent.h"
|
||||
#include "qapplication.h"
|
||||
#include "qpaintengine.h"
|
||||
|
@ -33,6 +32,7 @@
|
|||
#include "qwidget_p.h"
|
||||
#include "qwindowsurface_p.h"
|
||||
#include "qapplication_p.h"
|
||||
#include "qstdcontainers_p.h"
|
||||
#include "qpaintengine_raster_p.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
@ -659,7 +659,7 @@ void QWidgetBackingStore::sync()
|
|||
// painted (in case someone calls update() in paintEvent). If the widget is opaque
|
||||
// and does not have transparent overlapping siblings, append it to the
|
||||
// opaqueNonOverlappedWidgets list and paint it directly without composition.
|
||||
QVarLengthArray<QWidget *> opaqueNonOverlappedWidgets;
|
||||
QStdVector<QWidget *> opaqueNonOverlappedWidgets;
|
||||
for (int i = 0; i < dirtyWidgets.size(); ++i) {
|
||||
QWidget *w = dirtyWidgets.at(i);
|
||||
QWidgetPrivate *wd = w->d_func();
|
||||
|
|
|
@ -1980,7 +1980,7 @@ static void qt_merge_clip(const QClipData *c1, const QClipData *c2, QClipData *r
|
|||
{
|
||||
Q_ASSERT(c1->clipSpanHeight == c2->clipSpanHeight && c1->clipSpanHeight == result->clipSpanHeight);
|
||||
|
||||
QVarLengthArray<short> buffer;
|
||||
QStdVector<short> buffer;
|
||||
|
||||
QClipData::ClipLine *c1ClipLines = const_cast<QClipData *>(c1)->clipLines();
|
||||
QClipData::ClipLine *c2ClipLines = const_cast<QClipData *>(c2)->clipLines();
|
||||
|
|
|
@ -23,7 +23,6 @@
|
|||
#include "qpainter_p.h"
|
||||
#include "qstroker_p.h"
|
||||
#include "qpainterpath_p.h"
|
||||
#include "qvarlengtharray.h"
|
||||
#include "qdebug.h"
|
||||
#include "qcorecommon_p.h"
|
||||
|
||||
|
|
|
@ -35,12 +35,12 @@
|
|||
#include "qapplication.h"
|
||||
#include "qstyle.h"
|
||||
#include "qthread.h"
|
||||
#include "qvarlengtharray.h"
|
||||
#include "qpaintengine_p.h"
|
||||
#include "qpainterpath_p.h"
|
||||
#include "qwidget_p.h"
|
||||
#include "qpaintengine_raster_p.h"
|
||||
#include "qstylehelper_p.h"
|
||||
#include "qstdcontainers_p.h"
|
||||
#include "qguicommon_p.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
@ -5901,7 +5901,7 @@ void qt_format_text(const QFont &fnt, const QRectF &_r,
|
|||
|
||||
uint maxUnderlines = 0;
|
||||
int numUnderlines = 0;
|
||||
QVarLengthArray<int> underlinePositions(1);
|
||||
QStdVector<int> underlinePositions(1);
|
||||
|
||||
QFontMetricsF fm(fnt);
|
||||
QString text = str;
|
||||
|
|
|
@ -29,7 +29,6 @@
|
|||
#include "qpen.h"
|
||||
#include "qpolygon.h"
|
||||
#include "qtextlayout.h"
|
||||
#include "qvarlengtharray.h"
|
||||
#include "qmath.h"
|
||||
#include "qbezier_p.h"
|
||||
#include "qfontengine_p.h"
|
||||
|
|
|
@ -33,10 +33,9 @@
|
|||
// We mean it.
|
||||
//
|
||||
|
||||
#include "QtGui/qpainterpath.h"
|
||||
#include "QtCore/qlist.h"
|
||||
#include "QtCore/qvarlengtharray.h"
|
||||
|
||||
#include "qpainterpath.h"
|
||||
#include "qlist.h"
|
||||
#include "qstdcontainers_p.h"
|
||||
#include "qvectorpath_p.h"
|
||||
#include "qstroker_p.h"
|
||||
|
||||
|
@ -100,8 +99,8 @@ public:
|
|||
}
|
||||
|
||||
}
|
||||
QVarLengthArray<QPainterPath::ElementType> elements;
|
||||
QVarLengthArray<qreal> points;
|
||||
QStdVector<QPainterPath::ElementType> elements;
|
||||
QStdVector<qreal> points;
|
||||
uint flags;
|
||||
};
|
||||
|
||||
|
|
|
@ -1572,8 +1572,8 @@ void QPdfBaseEnginePrivate::drawTextItem(const QPointF &p, const QTextItemInt &t
|
|||
currentPage->fonts.append(font->object_id);
|
||||
|
||||
const qreal size = ti.fontEngine->fontDef.pixelSize;
|
||||
QVarLengthArray<glyph_t> glyphs;
|
||||
QVarLengthArray<QFixedPoint> positions;
|
||||
QStdVector<glyph_t> glyphs;
|
||||
QStdVector<QFixedPoint> positions;
|
||||
ti.fontEngine->getGlyphPositions(ti.glyphs, p, glyphs, positions);
|
||||
if (glyphs.size() == 0)
|
||||
return;
|
||||
|
|
|
@ -24,12 +24,12 @@
|
|||
#include "qpolygon.h"
|
||||
#include "qdatastream.h"
|
||||
#include "qvariant.h"
|
||||
#include "qvarlengtharray.h"
|
||||
#include "qdebug.h"
|
||||
#include "qimage.h"
|
||||
#include "qbitmap.h"
|
||||
#include "qscopedpointer.h"
|
||||
#include "qt_x11_p.h"
|
||||
#include "qstdcontainers_p.h"
|
||||
#include "qcorecommon_p.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
@ -3260,7 +3260,7 @@ static void PtsToRegion(int numFullPtBlocks, int iCurPtBlock,
|
|||
int lastRow = 0;
|
||||
int extendTo = 0;
|
||||
bool needsExtend = false;
|
||||
QVarLengthArray<QRegionSpan> row;
|
||||
QStdVector<QRegionSpan> row;
|
||||
int rowSize = 0;
|
||||
|
||||
reg->extents.setLeft(INT_MAX);
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
#include "qbitmap.h"
|
||||
#include "qpainter.h"
|
||||
#include "qpainterpath.h"
|
||||
#include "qvarlengtharray.h"
|
||||
#include "qmath.h"
|
||||
#include "qendian.h"
|
||||
#include "qdrawhelper_p.h"
|
||||
|
@ -89,7 +88,7 @@ QFixed QFontEngine::averageCharWidth() const
|
|||
|
||||
|
||||
void QFontEngine::getGlyphPositions(const QGlyphLayout &glyphs, const QPointF &point,
|
||||
QVarLengthArray<glyph_t> &glyphs_out, QVarLengthArray<QFixedPoint> &positions)
|
||||
QStdVector<glyph_t> &glyphs_out, QStdVector<QFixedPoint> &positions)
|
||||
{
|
||||
QFixed xpos = QFixed::fromReal(point.x());
|
||||
QFixed ypos = QFixed::fromReal(point.y());
|
||||
|
@ -128,8 +127,8 @@ void QFontEngine::addOutlineToPath(qreal x, qreal y, const QGlyphLayout &glyphs,
|
|||
if (!glyphs.numGlyphs)
|
||||
return;
|
||||
|
||||
QVarLengthArray<QFixedPoint> positions;
|
||||
QVarLengthArray<glyph_t> positioned_glyphs;
|
||||
QStdVector<QFixedPoint> positions;
|
||||
QStdVector<glyph_t> positioned_glyphs;
|
||||
getGlyphPositions(glyphs, QPointF(x, y), positioned_glyphs, positions);
|
||||
addGlyphsToPath(positioned_glyphs.data(), positions.data(), positioned_glyphs.size(), path);
|
||||
}
|
||||
|
@ -338,8 +337,8 @@ void QFontEngineBox::addOutlineToPath(qreal x, qreal y, const QGlyphLayout &glyp
|
|||
if (!glyphs.numGlyphs)
|
||||
return;
|
||||
|
||||
QVarLengthArray<QFixedPoint> positions;
|
||||
QVarLengthArray<glyph_t> positioned_glyphs;
|
||||
QStdVector<QFixedPoint> positions;
|
||||
QStdVector<glyph_t> positioned_glyphs;
|
||||
getGlyphPositions(glyphs, QPointF(x, y - _size), positioned_glyphs, positions);
|
||||
|
||||
const QSize s(_size - 3, _size - 3);
|
||||
|
|
|
@ -33,8 +33,8 @@
|
|||
// We mean it.
|
||||
//
|
||||
|
||||
#include "QtCore/qatomic.h"
|
||||
#include <QtCore/qvarlengtharray.h>
|
||||
#include "qatomic.h"
|
||||
#include "qstdcontainers_p.h"
|
||||
#include "qtextengine_p.h"
|
||||
#include "qfont_p.h"
|
||||
|
||||
|
@ -112,7 +112,7 @@ public:
|
|||
QPainterPath *path) = 0;
|
||||
|
||||
void getGlyphPositions(const QGlyphLayout &glyphs, const QPointF &point,
|
||||
QVarLengthArray<glyph_t> &glyphs_out, QVarLengthArray<QFixedPoint> &positions);
|
||||
QStdVector<glyph_t> &glyphs_out, QStdVector<QFixedPoint> &positions);
|
||||
|
||||
virtual void addOutlineToPath(qreal, qreal, const QGlyphLayout &, QPainterPath *);
|
||||
|
||||
|
|
|
@ -28,7 +28,6 @@
|
|||
#include "qtextlist.h"
|
||||
#include "qdebug.h"
|
||||
#include "qregexp.h"
|
||||
#include "qvarlengtharray.h"
|
||||
#include "qtextcodec.h"
|
||||
#include "qthread.h"
|
||||
#include "qtexthtmlparser_p.h"
|
||||
|
@ -43,7 +42,7 @@
|
|||
#include "qfont_p.h"
|
||||
#include "qtextedit_p.h"
|
||||
#include "qdataurl_p.h"
|
||||
|
||||
#include "qstdcontainers_p.h"
|
||||
#include "qtextdocument_p.h"
|
||||
#include "qprinter_p.h"
|
||||
#include "qabstracttextdocumentlayout_p.h"
|
||||
|
@ -2586,7 +2585,7 @@ void QTextHtmlExporter::emitTable(const QTextTable *table)
|
|||
}
|
||||
Q_ASSERT(columnWidths.count() == columns);
|
||||
|
||||
QVarLengthArray<bool> widthEmittedForColumn(columns);
|
||||
QStdVector<bool> widthEmittedForColumn(columns);
|
||||
for (int i = 0; i < columns; ++i)
|
||||
widthEmittedForColumn[i] = false;
|
||||
|
||||
|
|
|
@ -33,11 +33,11 @@
|
|||
#include "qrect.h"
|
||||
#include "qpalette.h"
|
||||
#include "qdebug.h"
|
||||
#include "qvarlengtharray.h"
|
||||
#include "qstyle.h"
|
||||
#include "qbasictimer.h"
|
||||
#include "qfontmetrics.h"
|
||||
#include "qx11info_x11.h"
|
||||
#include "qstdcontainers_p.h"
|
||||
|
||||
#include <limits.h>
|
||||
|
||||
|
@ -935,7 +935,7 @@ void QTextDocumentLayoutPrivate::drawFrame(const QPointF &offset, QPainter *pain
|
|||
const int columns = table->columns();
|
||||
QTextTableData *td = static_cast<QTextTableData *>(data(table));
|
||||
|
||||
QVarLengthArray<int> selectedTableCells(context.selections.size() * 4);
|
||||
QStdVector<int> selectedTableCells(context.selections.size() * 4);
|
||||
for (int i = 0; i < context.selections.size(); ++i) {
|
||||
const QAbstractTextDocumentLayout::Selection &s = context.selections.at(i);
|
||||
int row_start = -1, col_start = -1, num_rows = -1, num_cols = -1;
|
||||
|
@ -1702,7 +1702,7 @@ recalc_minmax_widths:
|
|||
|
||||
// for variable columns distribute the remaining space
|
||||
if (variableCols > 0 && remainingWidth > 0) {
|
||||
QVarLengthArray<int> columnsWithProperMaxSize;
|
||||
QStdVector<int> columnsWithProperMaxSize;
|
||||
for (int i = 0; i < columns; ++i)
|
||||
if (columnWidthConstraints.at(i).type() == QTextLength::VariableLength
|
||||
&& td->maxWidths.at(i) != QFIXED_MAX)
|
||||
|
@ -1771,7 +1771,7 @@ recalc_minmax_widths:
|
|||
if (pageHeight <= 0)
|
||||
pageHeight = QFIXED_MAX;
|
||||
|
||||
QVarLengthArray<QFixed> heightToDistribute(columns);
|
||||
QStdVector<QFixed> heightToDistribute(columns);
|
||||
|
||||
td->headerHeight = 0;
|
||||
const int headerRowCount = qMin(table->format().headerRowCount(), rows - 1);
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
#include "qtextengine_p.h"
|
||||
#include "qabstracttextdocumentlayout.h"
|
||||
#include "qtextlayout.h"
|
||||
#include "qvarlengtharray.h"
|
||||
#include "qfont.h"
|
||||
#include "qfontengine_p.h"
|
||||
#include "qunicodetables_p.h"
|
||||
|
@ -291,7 +290,7 @@ void QTextEngine::itemize() const
|
|||
if (!length)
|
||||
return;
|
||||
|
||||
QVarLengthArray<QScriptAnalysis> scriptAnalysis(length);
|
||||
QStdVector<QScriptAnalysis> scriptAnalysis(length);
|
||||
QScriptAnalysis *analysis = scriptAnalysis.data();
|
||||
|
||||
const ushort *uc = reinterpret_cast<const ushort *>(layoutData->string.unicode());
|
||||
|
@ -595,7 +594,7 @@ void QTextEngine::justify(const QScriptLine &line)
|
|||
int firstItem = findItem(line.from);
|
||||
int nItems = findItem(line.from + line_length - 1) - firstItem + 1;
|
||||
|
||||
QVarLengthArray<QJustificationPoint> justificationPoints;
|
||||
QStdVector<QJustificationPoint> justificationPoints;
|
||||
int nPoints = 0;
|
||||
// qDebug("justifying from %d len %d, firstItem=%d, nItems=%d (%s)", line.from, line_length, firstItem, nItems, layoutData->string.mid(line.from, line_length).toUtf8().constData());
|
||||
|
||||
|
|
|
@ -26,7 +26,6 @@
|
|||
#include "qapplication.h"
|
||||
#include "qmath.h"
|
||||
#include "qpainter.h"
|
||||
#include "qvarlengtharray.h"
|
||||
#include "qtextformat.h"
|
||||
#include "qabstracttextdocumentlayout.h"
|
||||
#include "qtextdocument_p.h"
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
#include "qtextformat.h"
|
||||
#include "qdebug.h"
|
||||
#include "qtexttable_p.h"
|
||||
#include "qvarlengtharray.h"
|
||||
#include "qstdcontainers_p.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
|
@ -1184,7 +1184,7 @@ void QTextTable::splitCell(int row, int column, int numRows, int numCols)
|
|||
|
||||
const int origCellPosition = cell.firstPosition() - 1;
|
||||
|
||||
QVarLengthArray<int> rowPositions(rowSpan);
|
||||
QStdVector<int> rowPositions(rowSpan);
|
||||
|
||||
rowPositions[0] = cell.lastPosition();
|
||||
|
||||
|
|
|
@ -32,10 +32,10 @@
|
|||
#include "qstyle.h"
|
||||
#include "qstyleoption.h"
|
||||
#include "qtextstream.h"
|
||||
#include "qvarlengtharray.h"
|
||||
#include "qvector.h"
|
||||
#include "qlayoutengine_p.h"
|
||||
#include "qsplitter_p.h"
|
||||
#include "qstdcontainers_p.h"
|
||||
#include "qtimer.h"
|
||||
#include "qdebug.h"
|
||||
|
||||
|
@ -1304,8 +1304,8 @@ void QSplitter::moveSplitter(int pos, int index)
|
|||
qDebug() << "QSplitter::moveSplitter" << debugp << index << "adjusted" << pos << "oldP" << oldP;
|
||||
#endif
|
||||
|
||||
QVarLengthArray<int> poss(d->list.count());
|
||||
QVarLengthArray<int> ws(d->list.count());
|
||||
QStdVector<int> poss(d->list.count());
|
||||
QStdVector<int> ws(d->list.count());
|
||||
bool upLeft;
|
||||
|
||||
d->doMove(false, pos, index, +1, (d->collapsible(s) && (pos > max)), poss.data(), ws.data());
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
#include "qdeclarativepixmapcache_p.h"
|
||||
#include <QAbstractAnimation>
|
||||
#include <QPainter>
|
||||
#include <QVarLengthArray>
|
||||
#include "qmath.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
|
|
@ -21,11 +21,13 @@
|
|||
|
||||
#include "Platform.h"
|
||||
#include "qscriptvalue.h"
|
||||
|
||||
#include "qscriptvalue_p.h"
|
||||
#include "qscriptengine.h"
|
||||
#include "qscriptengine_p.h"
|
||||
#include "qscriptstring_p.h"
|
||||
#include "qvariant.h"
|
||||
#include "qnumeric.h"
|
||||
#include "qstdcontainers_p.h"
|
||||
|
||||
#include "JSGlobalObject.h"
|
||||
#include "JSImmediate.h"
|
||||
|
@ -36,10 +38,6 @@
|
|||
#include "Operations.h"
|
||||
#include "Arguments.h"
|
||||
|
||||
#include <QtCore/qvariant.h>
|
||||
#include <QtCore/qvarlengtharray.h>
|
||||
#include <QtCore/qnumeric.h>
|
||||
|
||||
/*!
|
||||
\since 4.3
|
||||
\class QScriptValue
|
||||
|
@ -1532,7 +1530,7 @@ QScriptValue QScriptValue::call(const QScriptValue &thisObject,
|
|||
if (!jscThisObject || !jscThisObject.isObject())
|
||||
jscThisObject = d->engine->globalObject();
|
||||
|
||||
QVarLengthArray<JSC::JSValue> argsVector(args.size());
|
||||
QStdVector<JSC::JSValue> argsVector(args.size());
|
||||
for (int i = 0; i < args.size(); ++i) {
|
||||
const QScriptValue &arg = args.at(i);
|
||||
if (!arg.isValid()) {
|
||||
|
@ -1673,7 +1671,7 @@ QScriptValue QScriptValue::construct(const QScriptValueList &args)
|
|||
|
||||
JSC::ExecState *exec = d->engine->currentFrame;
|
||||
|
||||
QVarLengthArray<JSC::JSValue> argsVector(args.size());
|
||||
QStdVector<JSC::JSValue> argsVector(args.size());
|
||||
for (int i = 0; i < args.size(); ++i) {
|
||||
QScriptValue arg = args.at(i);
|
||||
if (Q_UNLIKELY(QScriptValuePrivate::getEngine(arg) != d->engine && QScriptValuePrivate::getEngine(arg))) {
|
||||
|
|
|
@ -22,10 +22,10 @@
|
|||
#include "Platform.h"
|
||||
#include "qscriptqobject_p.h"
|
||||
|
||||
#include <QtCore/qmetaobject.h>
|
||||
#include <QtCore/qvarlengtharray.h>
|
||||
#include <QtCore/qdebug.h>
|
||||
#include <QtScript/qscriptable.h>
|
||||
#include "qmetaobject.h"
|
||||
#include "qstdcontainers_p.h"
|
||||
#include "qdebug.h"
|
||||
#include "qscriptable.h"
|
||||
#include "../api/qscriptengine_p.h"
|
||||
#include "../api/qscriptable_p.h"
|
||||
#include "../api/qscriptcontext_p.h"
|
||||
|
@ -458,10 +458,10 @@ struct QScriptMetaArguments
|
|||
int matchDistance;
|
||||
int index;
|
||||
QScriptMetaMethod method;
|
||||
QVarLengthArray<QVariant> args;
|
||||
QStdVector<QVariant> args;
|
||||
|
||||
inline QScriptMetaArguments(int dist, int idx, const QScriptMetaMethod &mtd,
|
||||
const QVarLengthArray<QVariant> &as)
|
||||
const QStdVector<QVariant> &as)
|
||||
: matchDistance(dist), index(idx), method(mtd), args(as) { }
|
||||
inline QScriptMetaArguments()
|
||||
: index(-1) { }
|
||||
|
@ -492,7 +492,7 @@ static JSC::JSValue delegateQtMethod(JSC::ExecState *exec, QMetaMethod::MethodTy
|
|||
{
|
||||
QScriptMetaMethod chosenMethod;
|
||||
int chosenIndex = -1;
|
||||
QVarLengthArray<QVariant> args;
|
||||
QStdVector<QVariant> args;
|
||||
QVector<QScriptMetaArguments> candidates;
|
||||
QVector<QScriptMetaArguments> unresolved;
|
||||
QVector<int> tooFewArgs;
|
||||
|
@ -562,7 +562,7 @@ static JSC::JSValue delegateQtMethod(JSC::ExecState *exec, QMetaMethod::MethodTy
|
|||
if (!mtd.fullyResolved()) {
|
||||
// remember it so we can give an error message later, if necessary
|
||||
unresolved.append(QScriptMetaArguments(/*matchDistance=*/INT_MAX, index,
|
||||
mtd, QVarLengthArray<QVariant>()));
|
||||
mtd, QStdVector<QVariant>()));
|
||||
if (mtd.hasUnresolvedReturnType())
|
||||
continue;
|
||||
}
|
||||
|
@ -904,11 +904,11 @@ struct QtMethodCaller
|
|||
{}
|
||||
JSC::JSValue operator()(JSC::ExecState *exec, QMetaMethod::MethodType callType,
|
||||
const QMetaObject *meta, const QScriptMetaMethod &chosenMethod,
|
||||
int chosenIndex, const QVarLengthArray<QVariant> &args)
|
||||
int chosenIndex, const QStdVector<QVariant> &args)
|
||||
{
|
||||
JSC::JSValue result;
|
||||
|
||||
QVarLengthArray<void*> array(args.count());
|
||||
QStdVector<void*> array(args.count());
|
||||
void **params = array.data();
|
||||
for (int i = 0; i < args.count(); ++i) {
|
||||
const QVariant &v = args[i];
|
||||
|
@ -1037,7 +1037,7 @@ struct QtMethodIndexReturner
|
|||
{
|
||||
JSC::JSValue operator()(JSC::ExecState *exec, QMetaMethod::MethodType,
|
||||
const QMetaObject *, const QScriptMetaMethod &,
|
||||
int chosenIndex, const QVarLengthArray<QVariant> &)
|
||||
int chosenIndex, const QStdVector<QVariant> &)
|
||||
{
|
||||
return JSC::jsNumber(exec, chosenIndex);
|
||||
}
|
||||
|
@ -2181,7 +2181,7 @@ void QObjectConnectionManager::execute(int slotIndex, void **argv)
|
|||
int argc = parameterTypes.count();
|
||||
|
||||
JSC::ExecState *exec = engine->currentFrame;
|
||||
QVarLengthArray<JSC::JSValue> argsVector(argc);
|
||||
QStdVector<JSC::JSValue> argsVector(argc);
|
||||
for (int i = 0; i < argc; ++i) {
|
||||
JSC::JSValue actual;
|
||||
void *arg = argv[i + 1];
|
||||
|
|
|
@ -38,8 +38,8 @@
|
|||
#include "qfile.h"
|
||||
#include "qdebug.h"
|
||||
#include "qnumeric.h"
|
||||
#include "qvarlengtharray.h"
|
||||
#include "qmath.h"
|
||||
#include "qstdcontainers_p.h"
|
||||
#include "qcorecommon_p.h"
|
||||
|
||||
#include <float.h>
|
||||
|
@ -573,7 +573,7 @@ static QVector<qreal> parseNumbersList(const QChar *&str)
|
|||
return points;
|
||||
}
|
||||
|
||||
static inline void parseNumbersArray(const QChar *&str, QVarLengthArray<qreal> &points)
|
||||
static inline void parseNumbersArray(const QChar *&str, QStdVector<qreal> &points)
|
||||
{
|
||||
while (str->isSpace())
|
||||
++str;
|
||||
|
@ -957,7 +957,7 @@ static QMatrix parseTransformationMatrix(const QStringRef &value)
|
|||
if (*str != QLatin1Char('('))
|
||||
goto error;
|
||||
++str;
|
||||
QVarLengthArray<qreal> points;
|
||||
QStdVector<qreal> points;
|
||||
parseNumbersArray(str, points);
|
||||
if (*str != QLatin1Char(')'))
|
||||
goto error;
|
||||
|
@ -1387,7 +1387,7 @@ static bool parsePathDataFast(const QStringRef &dataStr, QPainterPath &path)
|
|||
++str;
|
||||
QChar endc = *end;
|
||||
*const_cast<QChar *>(end) = 0; // parseNumbersArray requires 0-termination that QStringRef cannot guarantee
|
||||
QVarLengthArray<qreal> arg;
|
||||
QStdVector<qreal> arg;
|
||||
parseNumbersArray(str, arg);
|
||||
*const_cast<QChar *>(end) = endc;
|
||||
if (pathElem == QLatin1Char('z') || pathElem == QLatin1Char('Z'))
|
||||
|
|
|
@ -26,7 +26,6 @@
|
|||
#include "qobject.h"
|
||||
#include "qstringlist.h"
|
||||
#include "qvector.h"
|
||||
#include "qvarlengtharray.h"
|
||||
#include "qcoreapplication.h"
|
||||
#include "qfile.h"
|
||||
#include "qdir.h"
|
||||
|
@ -40,6 +39,7 @@
|
|||
#include "qtestresult_p.h"
|
||||
#include "qsignaldumper_p.h"
|
||||
#include "qbenchmark_p.h"
|
||||
#include "qstdcontainers_p.h"
|
||||
#include "qcorecommon_p.h"
|
||||
|
||||
#include <stdarg.h>
|
||||
|
@ -1724,7 +1724,7 @@ int QTest::qExec(QObject *testObject, int argc, char **argv)
|
|||
int QTest::qExec(QObject *testObject, const QStringList &arguments)
|
||||
{
|
||||
const int argc = arguments.count();
|
||||
QVarLengthArray<char *> argv(argc);
|
||||
QStdVector<char *> argv(argc);
|
||||
|
||||
QVector<QByteArray> args;
|
||||
args.reserve(argc);
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
|
||||
#include <QByteArray>
|
||||
#include <QString>
|
||||
#include <QVarLengthArray>
|
||||
#include <QFile>
|
||||
#include <QProcess>
|
||||
#include <QMetaObject>
|
||||
|
@ -29,6 +28,7 @@
|
|||
#include <QRegExp>
|
||||
#include <QCoreApplication>
|
||||
#include <QLibraryInfo>
|
||||
#include "qstdcontainers_p.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -111,7 +111,7 @@ QByteArray MocParser::readLine()
|
|||
void MocParser::loadIntData(uint *&data)
|
||||
{
|
||||
data = 0; // initialise
|
||||
QVarLengthArray<uint> array;
|
||||
QStdVector<uint> array;
|
||||
QRegExp rx(QLatin1String("(\\d+|0x[0-9abcdef]+)"), Qt::CaseInsensitive);
|
||||
|
||||
while (!input->atEnd()) {
|
||||
|
@ -144,7 +144,7 @@ void MocParser::loadIntData(uint *&data)
|
|||
void MocParser::loadStringData(char *&stringdata)
|
||||
{
|
||||
stringdata = 0;
|
||||
QVarLengthArray<char> array;
|
||||
QStdVector<char> array;
|
||||
|
||||
while (!input->atEnd()) {
|
||||
QByteArray line = readLine();
|
||||
|
|
|
@ -532,7 +532,6 @@ static const struct ClassTblData {
|
|||
{ QLatin1String("QUrl"), QLatin1String("QtCore/qurl.h") },
|
||||
{ QLatin1String("QVBoxLayout"), QLatin1String("QtGui/qboxlayout.h") },
|
||||
{ QLatin1String("QValidator"), QLatin1String("QtGui/qvalidator.h") },
|
||||
{ QLatin1String("QVarLengthArray"), QLatin1String("QtCore/qvarlengtharray.h") },
|
||||
{ QLatin1String("QVariant"), QLatin1String("QtCore/qvariant.h") },
|
||||
{ QLatin1String("QVariantAnimation"), QLatin1String("QtGui/qvariantanimation.h") },
|
||||
{ QLatin1String("QVector"), QLatin1String("QtCore/qvector.h") },
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
|
||||
#include <QtTest>
|
||||
#include <QtDBus>
|
||||
#include <QtCore/QVarLengthArray>
|
||||
#include <QtCore/QThread>
|
||||
#include <QtCore/QObject>
|
||||
#include <QtCore/QSemaphore>
|
||||
|
@ -176,9 +175,9 @@ Thread::Thread(bool automatic)
|
|||
|
||||
void Thread::run()
|
||||
{
|
||||
QVarLengthArray<char> name;
|
||||
QByteArray name;
|
||||
name.append(QTest::currentTestFunction(), qstrlen(QTest::currentTestFunction()));
|
||||
name.append("_thread", sizeof "_thread");
|
||||
name.append("_thread", sizeof("_thread"));
|
||||
QMetaObject::invokeMethod(tst_QDBusThreading::self(), name.constData(), Qt::DirectConnection);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,3 +0,0 @@
|
|||
katie_test(tst_qvarlengtharray
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/tst_qvarlengtharray.cpp
|
||||
)
|
|
@ -1,591 +0,0 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2015 The Qt Company Ltd.
|
||||
** Copyright (C) 2016 Ivailo Monev
|
||||
**
|
||||
** This file is part of the test suite of the Katie Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
|
||||
#include <QtTest/QtTest>
|
||||
#include <qvarlengtharray.h>
|
||||
#include <qvariant.h>
|
||||
|
||||
//TESTED_CLASS=
|
||||
//TESTED_FILES=
|
||||
|
||||
class tst_QVarLengthArray : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
tst_QVarLengthArray() {}
|
||||
virtual ~tst_QVarLengthArray() {}
|
||||
|
||||
private slots:
|
||||
void append();
|
||||
void removeLast();
|
||||
void oldTests();
|
||||
void task214223();
|
||||
void QTBUG6718_resize();
|
||||
void QTBUG10978_realloc();
|
||||
};
|
||||
|
||||
int fooCtor = 0;
|
||||
int fooDtor = 0;
|
||||
|
||||
struct Foo
|
||||
{
|
||||
int *p;
|
||||
|
||||
Foo() { p = new int; ++fooCtor; }
|
||||
Foo(const Foo &/*other*/) { p = new int; ++fooCtor; }
|
||||
|
||||
void operator=(const Foo & /* other */) { }
|
||||
|
||||
~Foo() { delete p; ++fooDtor; }
|
||||
};
|
||||
|
||||
void tst_QVarLengthArray::append()
|
||||
{
|
||||
QVarLengthArray<QString> v;
|
||||
v.append(QString("hello"));
|
||||
QCOMPARE(v.at(0), QString("hello"));
|
||||
v.append(QString("hello2"));
|
||||
QCOMPARE(v.at(1), QString("hello2"));
|
||||
|
||||
QVarLengthArray<int> v2; // rocket!
|
||||
v2.append(5);
|
||||
QCOMPARE(v2.at(0), 5);
|
||||
v2.append(10);
|
||||
QCOMPARE(v2.at(1), 10);
|
||||
}
|
||||
|
||||
void tst_QVarLengthArray::removeLast()
|
||||
{
|
||||
{
|
||||
QVarLengthArray<char> v;
|
||||
v.append(0);
|
||||
v.append(1);
|
||||
QCOMPARE(v.size(), 2);
|
||||
v.append(2);
|
||||
v.append(3);
|
||||
QCOMPARE(v.size(), 4);
|
||||
v.removeLast();
|
||||
QCOMPARE(v.size(), 3);
|
||||
v.removeLast();
|
||||
QCOMPARE(v.size(), 2);
|
||||
}
|
||||
|
||||
{
|
||||
QVarLengthArray<QString> v;
|
||||
v.append("0");
|
||||
v.append("1");
|
||||
QCOMPARE(v.size(), 2);
|
||||
v.append("2");
|
||||
v.append("3");
|
||||
QCOMPARE(v.size(), 4);
|
||||
v.removeLast();
|
||||
QCOMPARE(v.size(), 3);
|
||||
v.removeLast();
|
||||
QCOMPARE(v.size(), 2);
|
||||
}
|
||||
}
|
||||
|
||||
void tst_QVarLengthArray::oldTests()
|
||||
{
|
||||
{
|
||||
QVarLengthArray<int> sa(128);
|
||||
QVERIFY(sa.data() == &sa[0]);
|
||||
sa[0] = 0xfee;
|
||||
sa[10] = 0xff;
|
||||
QVERIFY(sa[0] == 0xfee);
|
||||
QVERIFY(sa[10] == 0xff);
|
||||
sa.resize(512);
|
||||
QVERIFY(sa.data() == &sa[0]);
|
||||
QVERIFY(sa[0] == 0xfee);
|
||||
QVERIFY(sa[10] == 0xff);
|
||||
QVERIFY(sa.at(0) == 0xfee);
|
||||
QVERIFY(sa.at(10) == 0xff);
|
||||
QVERIFY(sa.value(0) == 0xfee);
|
||||
QVERIFY(sa.value(10) == 0xff);
|
||||
QVERIFY(sa.value(1000) == 0);
|
||||
QVERIFY(sa.value(1000, 12) == 12);
|
||||
QVERIFY(sa.size() == 512);
|
||||
sa.reserve(1024);
|
||||
QVERIFY(sa.capacity() == 1024);
|
||||
QVERIFY(sa.size() == 512);
|
||||
}
|
||||
{
|
||||
QVarLengthArray<QString> sa(10);
|
||||
sa[0] = "Hello";
|
||||
sa[9] = "World";
|
||||
QVERIFY(*sa.data() == "Hello");
|
||||
QVERIFY(sa[9] == "World");
|
||||
sa.reserve(512);
|
||||
QVERIFY(*sa.data() == "Hello");
|
||||
QVERIFY(sa[9] == "World");
|
||||
sa.resize(512);
|
||||
QVERIFY(*sa.data() == "Hello");
|
||||
QVERIFY(sa[9] == "World");
|
||||
}
|
||||
{
|
||||
int arr[2] = {1, 2};
|
||||
QVarLengthArray<int> sa(10);
|
||||
QCOMPARE(sa.size(), 10);
|
||||
sa.append(arr, 2);
|
||||
QCOMPARE(sa.size(), 12);
|
||||
QCOMPARE(sa[10], 1);
|
||||
QCOMPARE(sa[11], 2);
|
||||
}
|
||||
{
|
||||
QString arr[2] = { QString("hello"), QString("world") };
|
||||
QVarLengthArray<QString> sa(10);
|
||||
QCOMPARE(sa.size(), 10);
|
||||
sa.append(arr, 2);
|
||||
QCOMPARE(sa.size(), 12);
|
||||
QCOMPARE(sa[10], QString("hello"));
|
||||
QCOMPARE(sa[11], QString("world"));
|
||||
QCOMPARE(sa.at(10), QString("hello"));
|
||||
QCOMPARE(sa.at(11), QString("world"));
|
||||
QCOMPARE(sa.value(10), QString("hello"));
|
||||
QCOMPARE(sa.value(11), QString("world"));
|
||||
QCOMPARE(sa.value(10000), QString());
|
||||
QCOMPARE(sa.value(1212112, QString("none")), QString("none"));
|
||||
QCOMPARE(sa.value(-12, QString("neg")), QString("neg"));
|
||||
|
||||
sa.append(arr, 1);
|
||||
QCOMPARE(sa.size(), 13);
|
||||
QCOMPARE(sa[12], QString("hello"));
|
||||
|
||||
sa.append(arr, 0);
|
||||
QCOMPARE(sa.size(), 13);
|
||||
}
|
||||
{
|
||||
// assignment operator and copy constructor
|
||||
|
||||
QVarLengthArray<int> sa(10);
|
||||
sa[5] = 5;
|
||||
|
||||
QVarLengthArray<int> sa2(10);
|
||||
sa2[5] = 6;
|
||||
sa2 = sa;
|
||||
QCOMPARE(sa2[5], 5);
|
||||
|
||||
QVarLengthArray<int> sa3(sa);
|
||||
QCOMPARE(sa3[5], 5);
|
||||
}
|
||||
|
||||
QSKIP("This test causes the machine to crash when allocating too much memory.", SkipSingle);
|
||||
{
|
||||
QVarLengthArray<Foo> a;
|
||||
const int N = 0x7fffffff / sizeof(Foo);
|
||||
const int Prealloc = a.capacity();
|
||||
const Foo *data0 = a.constData();
|
||||
|
||||
a.resize(N);
|
||||
if (a.size() == N) {
|
||||
QVERIFY(a.capacity() >= N);
|
||||
QCOMPARE(fooCtor, N);
|
||||
QCOMPARE(fooDtor, 0);
|
||||
|
||||
for (int i = 0; i < N; i += 35000)
|
||||
a[i] = Foo();
|
||||
} else {
|
||||
// this is the case we're actually testing
|
||||
QCOMPARE(a.size(), 0);
|
||||
QCOMPARE(a.capacity(), Prealloc);
|
||||
QCOMPARE(a.constData(), data0);
|
||||
QCOMPARE(fooCtor, 0);
|
||||
QCOMPARE(fooDtor, 0);
|
||||
|
||||
a.resize(5);
|
||||
QCOMPARE(a.size(), 5);
|
||||
QCOMPARE(a.capacity(), Prealloc);
|
||||
QCOMPARE(a.constData(), data0);
|
||||
QCOMPARE(fooCtor, 5);
|
||||
QCOMPARE(fooDtor, 0);
|
||||
|
||||
a.resize(Prealloc + 1);
|
||||
QCOMPARE(a.size(), Prealloc + 1);
|
||||
QVERIFY(a.capacity() >= Prealloc + 1);
|
||||
QVERIFY(a.constData() != data0);
|
||||
QCOMPARE(fooCtor, Prealloc + 6);
|
||||
QCOMPARE(fooDtor, 5);
|
||||
|
||||
const Foo *data1 = a.constData();
|
||||
|
||||
a.resize(0x10000000);
|
||||
QCOMPARE(a.size(), 0);
|
||||
QVERIFY(a.capacity() >= Prealloc + 1);
|
||||
QVERIFY(a.constData() == data1);
|
||||
QCOMPARE(fooCtor, Prealloc + 6);
|
||||
QCOMPARE(fooDtor, Prealloc + 6);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void tst_QVarLengthArray::task214223()
|
||||
{
|
||||
//creating a QVarLengthArray of the same size as the prealloc size
|
||||
// will make the next call to append(const T&) corrupt the memory
|
||||
// you should get a segfault pretty soon after that :-)
|
||||
QVarLengthArray<float> d(1);
|
||||
for (int i=0; i<30; i++)
|
||||
d.append(i);
|
||||
}
|
||||
|
||||
void tst_QVarLengthArray::QTBUG6718_resize()
|
||||
{
|
||||
//MOVABLE
|
||||
{
|
||||
QVarLengthArray<QVariant> values(1);
|
||||
QCOMPARE(values.size(), 1);
|
||||
values[0] = 1;
|
||||
values.resize(2);
|
||||
QCOMPARE(values[1], QVariant());
|
||||
QCOMPARE(values[0], QVariant(1));
|
||||
values[1] = 2;
|
||||
QCOMPARE(values[1], QVariant(2));
|
||||
QCOMPARE(values.size(), 2);
|
||||
}
|
||||
|
||||
//POD
|
||||
{
|
||||
QVarLengthArray<int> values(1);
|
||||
QCOMPARE(values.size(), 1);
|
||||
values[0] = 1;
|
||||
values.resize(2);
|
||||
QCOMPARE(values[0], 1);
|
||||
values[1] = 2;
|
||||
QCOMPARE(values[1], 2);
|
||||
QCOMPARE(values.size(), 2);
|
||||
}
|
||||
|
||||
//COMPLEX
|
||||
{
|
||||
QVarLengthArray<QVarLengthArray<QString>> values(1);
|
||||
QCOMPARE(values.size(), 1);
|
||||
values[0].resize(10);
|
||||
values.resize(2);
|
||||
QCOMPARE(values[1].size(), 0);
|
||||
QCOMPARE(values[0].size(), 10);
|
||||
values[1].resize(20);
|
||||
QCOMPARE(values[1].size(), 20);
|
||||
QCOMPARE(values.size(), 2);
|
||||
}
|
||||
}
|
||||
|
||||
struct MyBase
|
||||
{
|
||||
MyBase()
|
||||
: data(this)
|
||||
, isCopy(false)
|
||||
{
|
||||
++liveCount;
|
||||
}
|
||||
|
||||
MyBase(MyBase const &)
|
||||
: data(this)
|
||||
, isCopy(true)
|
||||
{
|
||||
++copyCount;
|
||||
++liveCount;
|
||||
}
|
||||
|
||||
MyBase & operator=(MyBase const &)
|
||||
{
|
||||
if (!isCopy) {
|
||||
isCopy = true;
|
||||
++copyCount;
|
||||
} else {
|
||||
++errorCount;
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
~MyBase()
|
||||
{
|
||||
if (isCopy) {
|
||||
if (!copyCount)
|
||||
++errorCount;
|
||||
else
|
||||
--copyCount;
|
||||
}
|
||||
|
||||
if (!liveCount)
|
||||
++errorCount;
|
||||
else
|
||||
--liveCount;
|
||||
}
|
||||
|
||||
bool hasMoved() const
|
||||
{
|
||||
return this != data;
|
||||
}
|
||||
|
||||
protected:
|
||||
MyBase const * const data;
|
||||
bool isCopy;
|
||||
|
||||
public:
|
||||
static int errorCount;
|
||||
static int liveCount;
|
||||
static int copyCount;
|
||||
};
|
||||
|
||||
int MyBase::errorCount = 0;
|
||||
int MyBase::liveCount = 0;
|
||||
int MyBase::copyCount = 0;
|
||||
|
||||
struct MyPrimitive
|
||||
: MyBase
|
||||
{
|
||||
MyPrimitive()
|
||||
{
|
||||
++errorCount;
|
||||
}
|
||||
|
||||
~MyPrimitive()
|
||||
{
|
||||
++errorCount;
|
||||
}
|
||||
|
||||
MyPrimitive(MyPrimitive const &other)
|
||||
: MyBase(other)
|
||||
{
|
||||
++errorCount;
|
||||
}
|
||||
};
|
||||
|
||||
struct MyMovable
|
||||
: MyBase
|
||||
{
|
||||
};
|
||||
|
||||
struct MyComplex
|
||||
: MyBase
|
||||
{
|
||||
};
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
Q_DECLARE_TYPEINFO(MyPrimitive, Q_PRIMITIVE_TYPE);
|
||||
Q_DECLARE_TYPEINFO(MyMovable, Q_MOVABLE_TYPE);
|
||||
Q_DECLARE_TYPEINFO(MyComplex, Q_COMPLEX_TYPE);
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
bool QTBUG10978_proceed = true;
|
||||
|
||||
template <class T>
|
||||
int countMoved(QVarLengthArray<T> const &c)
|
||||
{
|
||||
int result = 0;
|
||||
for (int i = 0; i < c.size(); ++i)
|
||||
if (c[i].hasMoved())
|
||||
++result;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void QTBUG10978_test()
|
||||
{
|
||||
QTBUG10978_proceed = false;
|
||||
|
||||
typedef QVarLengthArray<T> Container;
|
||||
enum {
|
||||
isStatic = QTypeInfo<T>::isStatic,
|
||||
isComplex = QTypeInfo<T>::isComplex,
|
||||
|
||||
isPrimitive = !isComplex && !isStatic,
|
||||
isMovable = !isStatic
|
||||
};
|
||||
|
||||
// Constructors
|
||||
Container a;
|
||||
QCOMPARE( MyBase::liveCount, 0 );
|
||||
QCOMPARE( MyBase::copyCount, 0 );
|
||||
|
||||
QVERIFY( a.capacity() >= 16 );
|
||||
QCOMPARE( a.size(), 0 );
|
||||
|
||||
Container b_real(8);
|
||||
Container const &b = b_real;
|
||||
QCOMPARE( MyBase::liveCount, isPrimitive ? 0 : 8 );
|
||||
QCOMPARE( MyBase::copyCount, 0 );
|
||||
|
||||
QVERIFY( b.capacity() >= 16 );
|
||||
QCOMPARE( b.size(), 8 );
|
||||
|
||||
// Assignment
|
||||
a = b;
|
||||
QCOMPARE( MyBase::liveCount, isPrimitive ? 0 : 16 );
|
||||
QCOMPARE( MyBase::copyCount, isComplex ? 8 : 0 );
|
||||
QVERIFY( a.capacity() >= 16 );
|
||||
QCOMPARE( a.size(), 8 );
|
||||
|
||||
QVERIFY( b.capacity() >= 16 );
|
||||
QCOMPARE( b.size(), 8 );
|
||||
|
||||
// append
|
||||
a.append(b.data(), b.size());
|
||||
QCOMPARE( MyBase::liveCount, isPrimitive ? 0 : 24 );
|
||||
QCOMPARE( MyBase::copyCount, isComplex ? 16 : 0 );
|
||||
|
||||
QVERIFY( a.capacity() >= 16 );
|
||||
QCOMPARE( a.size(), 16 );
|
||||
|
||||
QVERIFY( b.capacity() >= 16 );
|
||||
QCOMPARE( b.size(), 8 );
|
||||
|
||||
// removeLast
|
||||
a.removeLast();
|
||||
QCOMPARE( MyBase::liveCount, isPrimitive ? 0 : 23 );
|
||||
QCOMPARE( MyBase::copyCount, isComplex ? 15 : 0 );
|
||||
|
||||
QVERIFY( a.capacity() >= 16 );
|
||||
QCOMPARE( a.size(), 15 );
|
||||
|
||||
QVERIFY( b.capacity() >= 16 );
|
||||
QCOMPARE( b.size(), 8 );
|
||||
|
||||
// Movable types
|
||||
const int capacity = a.capacity();
|
||||
if (!isPrimitive)
|
||||
QCOMPARE( countMoved(a), 0 );
|
||||
|
||||
// Reserve, no re-allocation
|
||||
a.reserve(capacity);
|
||||
if (!isPrimitive)
|
||||
QCOMPARE( countMoved(a), 0 );
|
||||
QCOMPARE( MyBase::liveCount, isPrimitive ? 0 : 23 );
|
||||
QCOMPARE( MyBase::copyCount, isComplex ? 15 : 0 );
|
||||
|
||||
QCOMPARE( a.capacity(), capacity );
|
||||
QCOMPARE( a.size(), 15 );
|
||||
|
||||
QVERIFY( b.capacity() >= 16 );
|
||||
QCOMPARE( b.size(), 8 );
|
||||
|
||||
// Reserve, force re-allocation
|
||||
a.reserve(capacity * 2);
|
||||
if (!isPrimitive)
|
||||
QCOMPARE( countMoved(a), isMovable ? 15 : 0 );
|
||||
QCOMPARE( MyBase::liveCount, isPrimitive ? 0 : 23 );
|
||||
QCOMPARE( MyBase::copyCount, isComplex ? 15 : 0 );
|
||||
|
||||
QVERIFY( a.capacity() >= capacity * 2 );
|
||||
QCOMPARE( a.size(), 15 );
|
||||
|
||||
QVERIFY( b.capacity() >= 16 );
|
||||
QCOMPARE( b.size(), 8 );
|
||||
|
||||
// resize, grow
|
||||
a.resize(40);
|
||||
if (!isPrimitive)
|
||||
QCOMPARE( countMoved(a), isMovable ? 15 : 0 );
|
||||
QCOMPARE( MyBase::liveCount, isPrimitive ? 0 : 48 );
|
||||
QCOMPARE( MyBase::copyCount, isComplex ? 15 : 0 );
|
||||
|
||||
QVERIFY( a.capacity() >= a.size() );
|
||||
QCOMPARE( a.size(), 40 );
|
||||
|
||||
QVERIFY( b.capacity() >= 16 );
|
||||
QCOMPARE( b.size(), 8 );
|
||||
|
||||
// Copy constructor, allocate
|
||||
{
|
||||
Container c(a);
|
||||
if (!isPrimitive)
|
||||
QCOMPARE( countMoved(c), 0 );
|
||||
QCOMPARE( MyBase::liveCount, isPrimitive ? 0 : 88 );
|
||||
QCOMPARE( MyBase::copyCount, isComplex ? 55 : 0 );
|
||||
|
||||
QVERIFY( a.capacity() >= a.size() );
|
||||
QCOMPARE( a.size(), 40 );
|
||||
|
||||
QVERIFY( b.capacity() >= 16 );
|
||||
QCOMPARE( b.size(), 8 );
|
||||
|
||||
QVERIFY( c.capacity() >= 40 );
|
||||
QCOMPARE( c.size(), 40 );
|
||||
}
|
||||
|
||||
// resize, shrink
|
||||
a.resize(10);
|
||||
if (!isPrimitive)
|
||||
QCOMPARE( countMoved(a), isMovable ? 10 : 0 );
|
||||
QCOMPARE( MyBase::liveCount, isPrimitive ? 0 : 18 );
|
||||
QCOMPARE( MyBase::copyCount, isComplex ? 10 : 0 );
|
||||
|
||||
QVERIFY( a.capacity() >= a.size() );
|
||||
QCOMPARE( a.size(), 10 );
|
||||
|
||||
QVERIFY( b.capacity() >= 16 );
|
||||
QCOMPARE( b.size(), 8 );
|
||||
|
||||
// Copy constructor, don't allocate
|
||||
{
|
||||
Container c(a);
|
||||
if (!isPrimitive)
|
||||
QCOMPARE( countMoved(c), 0 );
|
||||
QCOMPARE( MyBase::liveCount, isPrimitive ? 0 : 28 );
|
||||
QCOMPARE( MyBase::copyCount, isComplex ? 20 : 0 );
|
||||
|
||||
QVERIFY( a.capacity() >= a.size() );
|
||||
QCOMPARE( a.size(), 10 );
|
||||
|
||||
QVERIFY( b.capacity() >= 16 );
|
||||
QCOMPARE( b.size(), 8 );
|
||||
|
||||
QVERIFY( c.capacity() >= 16 );
|
||||
QCOMPARE( c.size(), 10 );
|
||||
}
|
||||
|
||||
a.clear();
|
||||
QCOMPARE( a.size(), 0 );
|
||||
|
||||
b_real.clear();
|
||||
QCOMPARE( b.size(), 0 );
|
||||
|
||||
QCOMPARE(MyBase::errorCount, 0);
|
||||
QCOMPARE(MyBase::liveCount, 0);
|
||||
|
||||
// All done
|
||||
QTBUG10978_proceed = true;
|
||||
}
|
||||
|
||||
void tst_QVarLengthArray::QTBUG10978_realloc()
|
||||
{
|
||||
QTBUG10978_test<MyBase>();
|
||||
QVERIFY(QTBUG10978_proceed);
|
||||
|
||||
QTBUG10978_test<MyPrimitive>();
|
||||
QVERIFY(QTBUG10978_proceed);
|
||||
|
||||
QTBUG10978_test<MyMovable>();
|
||||
QVERIFY(QTBUG10978_proceed);
|
||||
|
||||
QTBUG10978_test<MyComplex>();
|
||||
QVERIFY(QTBUG10978_proceed);
|
||||
}
|
||||
|
||||
QTEST_APPLESS_MAIN(tst_QVarLengthArray)
|
||||
|
||||
#include "moc_tst_qvarlengtharray.cpp"
|
|
@ -8209,8 +8209,6 @@
|
|||
qtools_p.h
|
||||
qunicodetables.cpp
|
||||
qunicodetables_p.h
|
||||
qvarlengtharray.h
|
||||
qvarlengtharray.qdoc
|
||||
qvector.cpp
|
||||
qvector.h
|
||||
qvsnprintf.cpp
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
|
||||
#include "chip.h"
|
||||
|
||||
#include "QtCore/qvarlengtharray.h"
|
||||
#include <QVector>
|
||||
#include <QtGui>
|
||||
|
||||
Chip::Chip(const QColor &color, int x, int y)
|
||||
|
@ -102,7 +102,7 @@ void Chip::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWid
|
|||
}
|
||||
|
||||
// Draw lines
|
||||
QVarLengthArray<QLineF> lines;
|
||||
QVector<QLineF> lines;
|
||||
if (option->levelOfDetail >= 0.5) {
|
||||
for (int i = 0; i <= 10; i += (option->levelOfDetail > 0.5 ? 1 : 2)) {
|
||||
lines.append(QLineF(18 + 7 * i, 13, 18 + 7 * i, 5));
|
||||
|
|
Loading…
Add table
Reference in a new issue