summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2020-10-20 12:19:21 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2020-10-21 08:26:38 +0200
commit05685708b78b43713fbfc59ff78160340a38e2d1 (patch)
treeec5ee4bc4fdff1e176cd0698644bc893950054c2 /src/corelib
parent9aba868571e7448ea79229a31d18bfd3e69813f8 (diff)
Whitespace cleanup in corelib/tools
Change-Id: Ibe796c398a8e5488b7203abb07aa54740744f1ab Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/tools/qbitarray.cpp35
-rw-r--r--src/corelib/tools/qbitarray.h22
-rw-r--r--src/corelib/tools/qcache.h14
-rw-r--r--src/corelib/tools/qcommandlineparser.cpp2
-rw-r--r--src/corelib/tools/qcryptographichash.cpp12
-rw-r--r--src/corelib/tools/qcryptographichash.h2
-rw-r--r--src/corelib/tools/qeasingcurve.cpp47
-rw-r--r--src/corelib/tools/qeasingcurve.h8
-rw-r--r--src/corelib/tools/qfreelist.cpp6
-rw-r--r--src/corelib/tools/qfreelist_p.h3
-rw-r--r--src/corelib/tools/qhash.h25
-rw-r--r--src/corelib/tools/qhashfunctions.h6
-rw-r--r--src/corelib/tools/qiterator.h15
-rw-r--r--src/corelib/tools/qlist.h2
-rw-r--r--src/corelib/tools/qmakearray_p.h8
-rw-r--r--src/corelib/tools/qpoint.h151
-rw-r--r--src/corelib/tools/qrect.h22
-rw-r--r--src/corelib/tools/qscopedpointer.h5
-rw-r--r--src/corelib/tools/qsharedpointer.h2
-rw-r--r--src/corelib/tools/qsize.h96
-rw-r--r--src/corelib/tools/qtimeline.cpp4
-rw-r--r--src/corelib/tools/qtools_p.h3
-rw-r--r--src/corelib/tools/qvarlengtharray.h60
-rw-r--r--src/corelib/tools/qversionnumber.cpp4
-rw-r--r--src/corelib/tools/qversionnumber.h15
25 files changed, 349 insertions, 220 deletions
diff --git a/src/corelib/tools/qbitarray.cpp b/src/corelib/tools/qbitarray.cpp
index c13604abb8..18ce7035d9 100644
--- a/src/corelib/tools/qbitarray.cpp
+++ b/src/corelib/tools/qbitarray.cpp
@@ -145,17 +145,17 @@ QT_BEGIN_NAMESPACE
initialized with \a value, which defaults to false (0).
*/
QBitArray::QBitArray(qsizetype size, bool value)
- : d(size <= 0 ? 0 : 1 + (size + 7)/8, Qt::Uninitialized)
+ : d(size <= 0 ? 0 : 1 + (size + 7) / 8, Qt::Uninitialized)
{
Q_ASSERT_X(size >= 0, "QBitArray::QBitArray", "Size must be greater than or equal to 0.");
if (size <= 0)
return;
- uchar* c = reinterpret_cast<uchar*>(d.data());
+ uchar *c = reinterpret_cast<uchar *>(d.data());
memset(c + 1, value ? 0xff : 0, d.size() - 1);
- *c = d.size()*8 - size;
+ *c = d.size() * 8 - size;
if (value && size && size & 7)
- *(c+1+size/8) &= (1 << (size & 7)) - 1;
+ *(c + 1 + size / 8) &= (1 << (size & 7)) - 1;
}
/*! \fn qsizetype QBitArray::size() const
@@ -223,13 +223,13 @@ void QBitArray::resize(qsizetype size)
d.resize(0);
} else {
qsizetype s = d.size();
- d.resize(1 + (size+7)/8);
- uchar* c = reinterpret_cast<uchar*>(d.data());
+ d.resize(1 + (size + 7) / 8);
+ uchar *c = reinterpret_cast<uchar *>(d.data());
if (size > (s << 3))
memset(c + s, 0, d.size() - s);
else if (size & 7)
- *(c+1+size/8) &= (1 << (size & 7)) - 1;
- *c = d.size()*8 - size;
+ *(c + 1 + size / 8) &= (1 << (size & 7)) - 1;
+ *c = d.size() * 8 - size;
}
}
@@ -293,7 +293,7 @@ void QBitArray::fill(bool value, qsizetype begin, qsizetype end)
if (len <= 0)
return;
qsizetype s = len & ~qsizetype(0x7);
- uchar *c = reinterpret_cast<uchar*>(d.data());
+ uchar *c = reinterpret_cast<uchar *>(d.data());
memset(c + (begin >> 3) + 1, value ? 0xff : 0, s >> 3);
begin += s;
while (begin < end)
@@ -555,9 +555,9 @@ quint32 QBitArray::toUInt32(QSysInfo::Endian endianness, bool *ok) const noexcep
QBitArray &QBitArray::operator&=(const QBitArray &other)
{
resize(qMax(size(), other.size()));
- uchar *a1 = reinterpret_cast<uchar*>(d.data()) + 1;
- const uchar *a2 = reinterpret_cast<const uchar*>(other.d.constData()) + 1;
- qsizetype n = other.d.size() -1 ;
+ uchar *a1 = reinterpret_cast<uchar *>(d.data()) + 1;
+ const uchar *a2 = reinterpret_cast<const uchar *>(other.d.constData()) + 1;
+ qsizetype n = other.d.size() - 1;
qsizetype p = d.size() - 1 - n;
while (n-- > 0)
*a1++ &= *a2++;
@@ -584,7 +584,7 @@ QBitArray &QBitArray::operator&=(const QBitArray &other)
QBitArray &QBitArray::operator|=(const QBitArray &other)
{
resize(qMax(size(), other.size()));
- uchar *a1 = reinterpret_cast<uchar*>(d.data()) + 1;
+ uchar *a1 = reinterpret_cast<uchar *>(d.data()) + 1;
const uchar *a2 = reinterpret_cast<const uchar *>(other.d.constData()) + 1;
qsizetype n = other.d.size() - 1;
while (n-- > 0)
@@ -610,7 +610,7 @@ QBitArray &QBitArray::operator|=(const QBitArray &other)
QBitArray &QBitArray::operator^=(const QBitArray &other)
{
resize(qMax(size(), other.size()));
- uchar *a1 = reinterpret_cast<uchar*>(d.data()) + 1;
+ uchar *a1 = reinterpret_cast<uchar *>(d.data()) + 1;
const uchar *a2 = reinterpret_cast<const uchar *>(other.d.constData()) + 1;
qsizetype n = other.d.size() - 1;
while (n-- > 0)
@@ -633,14 +633,14 @@ QBitArray QBitArray::operator~() const
qsizetype sz = size();
QBitArray a(sz);
const uchar *a1 = reinterpret_cast<const uchar *>(d.constData()) + 1;
- uchar *a2 = reinterpret_cast<uchar*>(a.d.data()) + 1;
+ uchar *a2 = reinterpret_cast<uchar *>(a.d.data()) + 1;
qsizetype n = d.size() - 1;
while (n-- > 0)
*a2++ = ~*a1++;
- if (sz && sz%8)
- *(a2-1) &= (1 << (sz%8)) - 1;
+ if (sz && sz % 8)
+ *(a2 - 1) &= (1 << (sz % 8)) - 1;
return a;
}
@@ -754,7 +754,6 @@ QBitArray operator^(const QBitArray &a1, const QBitArray &a2)
Sets the value referenced by the QBitRef to \a v.
*/
-
/*****************************************************************************
QBitArray stream functions
*****************************************************************************/
diff --git a/src/corelib/tools/qbitarray.h b/src/corelib/tools/qbitarray.h
index 8a1e229364..75d680dc84 100644
--- a/src/corelib/tools/qbitarray.h
+++ b/src/corelib/tools/qbitarray.h
@@ -44,7 +44,6 @@
QT_BEGIN_NAMESPACE
-
class QBitRef;
class Q_CORE_EXPORT QBitArray
{
@@ -88,13 +87,13 @@ public:
QBitRef operator[](qsizetype i);
bool operator[](qsizetype i) const;
- QBitArray& operator&=(const QBitArray &);
- QBitArray& operator|=(const QBitArray &);
- QBitArray& operator^=(const QBitArray &);
- QBitArray operator~() const;
+ QBitArray &operator&=(const QBitArray &);
+ QBitArray &operator|=(const QBitArray &);
+ QBitArray &operator^=(const QBitArray &);
+ QBitArray operator~() const;
- inline bool operator==(const QBitArray& other) const { return d == other.d; }
- inline bool operator!=(const QBitArray& other) const { return d != other.d; }
+ inline bool operator==(const QBitArray &other) const { return d == other.d; }
+ inline bool operator!=(const QBitArray &other) const { return d != other.d; }
inline bool fill(bool val, qsizetype size = -1);
void fill(bool val, qsizetype first, qsizetype last);
@@ -144,15 +143,16 @@ inline bool QBitArray::at(qsizetype i) const { return testBit(i); }
class Q_CORE_EXPORT QBitRef
{
private:
- QBitArray& a;
+ QBitArray &a;
qsizetype i;
- inline QBitRef(QBitArray& array, qsizetype idx) : a(array), i(idx) {}
+ inline QBitRef(QBitArray &array, qsizetype idx) : a(array), i(idx) { }
friend class QBitArray;
+
public:
inline operator bool() const { return a.testBit(i); }
inline bool operator!() const { return !a.testBit(i); }
- QBitRef& operator=(const QBitRef& val) { a.setBit(i, val); return *this; }
- QBitRef& operator=(bool val) { a.setBit(i, val); return *this; }
+ QBitRef &operator=(const QBitRef &val) { a.setBit(i, val); return *this; }
+ QBitRef &operator=(bool val) { a.setBit(i, val); return *this; }
};
inline QBitRef QBitArray::operator[](qsizetype i)
diff --git a/src/corelib/tools/qcache.h b/src/corelib/tools/qcache.h
index c8de12af60..868b4a5854 100644
--- a/src/corelib/tools/qcache.h
+++ b/src/corelib/tools/qcache.h
@@ -48,7 +48,8 @@ QT_BEGIN_NAMESPACE
template <class Key, class T>
class QCache
{
- struct Value {
+ struct Value
+ {
T *t = nullptr;
qsizetype cost = 0;
Value() noexcept = default;
@@ -68,19 +69,20 @@ class QCache
return *this;
}
~Value() { delete t; }
+
private:
Q_DISABLE_COPY(Value)
};
- struct Chain {
- Chain() noexcept
- : prev(this), next(this)
- {}
+ struct Chain
+ {
+ Chain() noexcept : prev(this), next(this) { }
Chain *prev;
Chain *next;
};
- struct Node : public Chain {
+ struct Node : public Chain
+ {
using KeyType = Key;
using ValueType = Value;
diff --git a/src/corelib/tools/qcommandlineparser.cpp b/src/corelib/tools/qcommandlineparser.cpp
index 1b93fb84cf..99e7484664 100644
--- a/src/corelib/tools/qcommandlineparser.cpp
+++ b/src/corelib/tools/qcommandlineparser.cpp
@@ -1135,7 +1135,7 @@ QString QCommandLineParserPrivate::helpText(bool includeQtOptions) const
usage += QLatin1Char(' ') + arg.syntax;
text += QCommandLineParser::tr("Usage: %1").arg(usage) + nl;
if (!description.isEmpty())
- text += description + nl;
+ text += description + nl;
text += nl;
if (!options.isEmpty())
text += QCommandLineParser::tr("Options:") + nl;
diff --git a/src/corelib/tools/qcryptographichash.cpp b/src/corelib/tools/qcryptographichash.cpp
index 3070ac4b05..47b72038eb 100644
--- a/src/corelib/tools/qcryptographichash.cpp
+++ b/src/corelib/tools/qcryptographichash.cpp
@@ -445,7 +445,7 @@ void QCryptographicHash::addData(const QByteArray &data)
and hashes it. Returns \c true if reading was successful.
\since 5.0
*/
-bool QCryptographicHash::addData(QIODevice* device)
+bool QCryptographicHash::addData(QIODevice *device)
{
if (!device->isReadable())
return false;
@@ -456,8 +456,8 @@ bool QCryptographicHash::addData(QIODevice* device)
char buffer[1024];
int length;
- while ((length = device->read(buffer,sizeof(buffer))) > 0)
- addData(buffer,length);
+ while ((length = device->read(buffer, sizeof(buffer))) > 0)
+ addData(buffer, length);
return device->atEnd();
}
@@ -505,19 +505,19 @@ QByteArray QCryptographicHash::result() const
SHA224Result(&copy, reinterpret_cast<unsigned char *>(d->result.data()));
break;
}
- case Sha256:{
+ case Sha256: {
SHA256Context copy = d->sha256Context;
d->result.resize(SHA256HashSize);
SHA256Result(&copy, reinterpret_cast<unsigned char *>(d->result.data()));
break;
}
- case Sha384:{
+ case Sha384: {
SHA384Context copy = d->sha384Context;
d->result.resize(SHA384HashSize);
SHA384Result(&copy, reinterpret_cast<unsigned char *>(d->result.data()));
break;
}
- case Sha512:{
+ case Sha512: {
SHA512Context copy = d->sha512Context;
d->result.resize(SHA512HashSize);
SHA512Result(&copy, reinterpret_cast<unsigned char *>(d->result.data()));
diff --git a/src/corelib/tools/qcryptographichash.h b/src/corelib/tools/qcryptographichash.h
index bef0c4dbe1..4d76d06e59 100644
--- a/src/corelib/tools/qcryptographichash.h
+++ b/src/corelib/tools/qcryptographichash.h
@@ -105,7 +105,7 @@ public:
void addData(const char *data, qsizetype length);
void addData(const QByteArray &data);
- bool addData(QIODevice* device);
+ bool addData(QIODevice *device);
QByteArray result() const;
diff --git a/src/corelib/tools/qeasingcurve.cpp b/src/corelib/tools/qeasingcurve.cpp
index 389efcb8f9..9eb74d12cc 100644
--- a/src/corelib/tools/qeasingcurve.cpp
+++ b/src/corelib/tools/qeasingcurve.cpp
@@ -320,7 +320,8 @@ static bool isConfigFunction(QEasingCurve::Type type)
type == QEasingCurve::TCBSpline;
}
-struct TCBPoint {
+struct TCBPoint
+{
QPointF _point;
qreal _t;
qreal _c;
@@ -605,8 +606,8 @@ struct BezierEase : public QEasingCurveFunction
const qreal s = 1 - t;
- const qreal s_squared = s*s;
- const qreal t_squared = t*t;
+ const qreal s_squared = s * s;
+ const qreal t_squared = t * t;
const qreal s_cubic = s_squared * s;
const qreal t_cubic = t_squared * t;
@@ -623,8 +624,8 @@ struct BezierEase : public QEasingCurveFunction
const qreal s = 1 - t;
- const qreal s_squared = s*s;
- const qreal t_squared = t*t;
+ const qreal s_squared = s * s;
+ const qreal t_squared = t * t;
const qreal s_cubic = s_squared * s;
const qreal t_cubic = t_squared * t;
@@ -639,7 +640,7 @@ struct BezierEase : public QEasingCurveFunction
const qreal p2 = singleCubicBezier.p2x;
const qreal p3 = singleCubicBezier.p3x;
- const qreal t_squared = t*t;
+ const qreal t_squared = t * t;
return -3*p0 + 3*p1 + 6*p0*t - 12*p1*t + 6*p2*t + 3*p3*t_squared - 3*p0*t_squared + 9*p1*t_squared - 9*p2*t_squared;
}
@@ -739,7 +740,7 @@ struct BezierEase : public QEasingCurveFunction
qreal cos = b * x - a * x_squared;
if (cos < 0)
- return 0.225 * (cos * 1 *-cos - cos) + cos;
+ return 0.225 * (cos * 1 * -cos - cos) + cos;
return 0.225 * (cos * cos - cos) + cos;
}
@@ -794,15 +795,15 @@ struct BezierEase : public QEasingCurveFunction
if (D >= 0) {
const qreal D_sqrt = qSqrt(D);
- qreal u = _cbrt( -q * 0.5 + D_sqrt);
- qreal v = _cbrt( -q * 0.5 - D_sqrt);
+ qreal u = _cbrt(-q * 0.5 + D_sqrt);
+ qreal v = _cbrt(-q * 0.5 - D_sqrt);
qreal z1 = u + v;
qreal t1 = z1 - a_by3;
if (inRange(t1))
return t1;
- qreal z2 = -1 *u;
+ qreal z2 = -1 * u;
qreal t2 = z2 - a_by3;
return t2;
}
@@ -825,7 +826,7 @@ struct BezierEase : public QEasingCurveFunction
cosacos(g, s1, s2, s3);
- qreal z1 = -1* f * s2;
+ qreal z1 = -1 * f * s2;
qreal t1 = z1 - a_by3;
if (inRange(t1))
return t1;
@@ -940,7 +941,7 @@ struct ElasticEase : public QEasingCurveFunction
{
qreal p = (_p < 0) ? qreal(0.3) : _p;
qreal a = (_a < 0) ? qreal(1.0) : _a;
- switch(_t) {
+ switch (_t) {
case QEasingCurve::InElastic:
return easeInElastic(t, a, p);
case QEasingCurve::OutElastic:
@@ -973,7 +974,7 @@ struct BounceEase : public QEasingCurveFunction
qreal value(qreal t) override
{
qreal a = (_a < 0) ? qreal(1.0) : _a;
- switch(_t) {
+ switch (_t) {
case QEasingCurve::InBounce:
return easeInBounce(t, a);
case QEasingCurve::OutBounce:
@@ -1011,7 +1012,7 @@ struct BackEase : public QEasingCurveFunction
if (!(t < 1))
return 1;
qreal o = (_o < 0) ? qreal(1.70158) : _o;
- switch(_t) {
+ switch (_t) {
case QEasingCurve::InBack:
return easeInBack(t, o);
case QEasingCurve::OutBack:
@@ -1028,7 +1029,7 @@ struct BackEase : public QEasingCurveFunction
static QEasingCurve::EasingFunction curveToFunc(QEasingCurve::Type curve)
{
- switch(curve) {
+ switch (curve) {
case QEasingCurve::Linear:
return &easeNone;
case QEasingCurve::InQuad:
@@ -1103,7 +1104,7 @@ static QEasingCurve::EasingFunction curveToFunc(QEasingCurve::Type curve)
static QEasingCurveFunction *curveToFunctionObject(QEasingCurve::Type type)
{
- switch(type) {
+ switch (type) {
case QEasingCurve::InElastic:
case QEasingCurve::OutElastic:
case QEasingCurve::InOutElastic:
@@ -1197,14 +1198,14 @@ bool QEasingCurve::operator==(const QEasingCurve &other) const
&& d_ptr->type == other.d_ptr->type;
if (res) {
if (d_ptr->config && other.d_ptr->config) {
- // catch the config content
+ // catch the config content
res = d_ptr->config->operator==(*(other.d_ptr->config));
} else if (d_ptr->config || other.d_ptr->config) {
- // one one has a config object, which could contain default values
- res = qFuzzyCompare(amplitude(), other.amplitude()) &&
- qFuzzyCompare(period(), other.period()) &&
- qFuzzyCompare(overshoot(), other.overshoot());
+ // one one has a config object, which could contain default values
+ res = qFuzzyCompare(amplitude(), other.amplitude())
+ && qFuzzyCompare(period(), other.period())
+ && qFuzzyCompare(overshoot(), other.overshoot());
}
}
return res;
@@ -1275,7 +1276,7 @@ void QEasingCurve::setPeriod(qreal period)
*/
qreal QEasingCurve::overshoot() const
{
- return d_ptr->config ? d_ptr->config->_o : qreal(1.70158) ;
+ return d_ptr->config ? d_ptr->config->_o : qreal(1.70158);
}
/*!
@@ -1372,7 +1373,7 @@ void QEasingCurve::addTCBSegment(const QPointF &nextPoint, qreal t, qreal c, qre
if (!d_ptr->config)
d_ptr->config = curveToFunctionObject(d_ptr->type);
- d_ptr->config->_tcbPoints.append(TCBPoint(nextPoint, t, c ,b));
+ d_ptr->config->_tcbPoints.append(TCBPoint(nextPoint, t, c, b));
if (nextPoint == QPointF(1.0, 1.0)) {
d_ptr->config->_bezierCurves = tcbToBezier(d_ptr->config->_tcbPoints);
diff --git a/src/corelib/tools/qeasingcurve.h b/src/corelib/tools/qeasingcurve.h
index 93aec81aa0..7e50743bf1 100644
--- a/src/corelib/tools/qeasingcurve.h
+++ b/src/corelib/tools/qeasingcurve.h
@@ -49,7 +49,6 @@ QT_REQUIRE_CONFIG(easingcurve);
QT_BEGIN_NAMESPACE
-
class QEasingCurvePrivate;
class QPointF;
class Q_CORE_EXPORT QEasingCurve
@@ -97,7 +96,7 @@ public:
qreal overshoot() const;
void setOvershoot(qreal overshoot);
- void addCubicBezierSegment(const QPointF & c1, const QPointF & c2, const QPointF & endPoint);
+ void addCubicBezierSegment(const QPointF &c1, const QPointF &c2, const QPointF &endPoint);
void addTCBSegment(const QPointF &nextPoint, qreal t, qreal c, qreal b);
QList<QPointF> toCubicSpline() const;
@@ -108,13 +107,14 @@ public:
EasingFunction customType() const;
qreal valueForProgress(qreal progress) const;
+
private:
QEasingCurvePrivate *d_ptr;
#ifndef QT_NO_DEBUG_STREAM
friend Q_CORE_EXPORT QDebug operator<<(QDebug debug, const QEasingCurve &item);
#endif
#ifndef QT_NO_DATASTREAM
- friend Q_CORE_EXPORT QDataStream &operator<<(QDataStream &, const QEasingCurve&);
+ friend Q_CORE_EXPORT QDataStream &operator<<(QDataStream &, const QEasingCurve &);
friend Q_CORE_EXPORT QDataStream &operator>>(QDataStream &, QEasingCurve &);
#endif
};
@@ -125,7 +125,7 @@ Q_CORE_EXPORT QDebug operator<<(QDebug debug, const QEasingCurve &item);
#endif
#ifndef QT_NO_DATASTREAM
-Q_CORE_EXPORT QDataStream &operator<<(QDataStream &, const QEasingCurve&);
+Q_CORE_EXPORT QDataStream &operator<<(QDataStream &, const QEasingCurve &);
Q_CORE_EXPORT QDataStream &operator>>(QDataStream &, QEasingCurve &);
#endif
diff --git a/src/corelib/tools/qfreelist.cpp b/src/corelib/tools/qfreelist.cpp
index dd584413fc..38ad13a1ee 100644
--- a/src/corelib/tools/qfreelist.cpp
+++ b/src/corelib/tools/qfreelist.cpp
@@ -48,9 +48,9 @@ enum {
Offset2 = 0x00080000,
Offset3 = 0x00800000,
- Size0 = Offset1 - Offset0,
- Size1 = Offset2 - Offset1,
- Size2 = Offset3 - Offset2,
+ Size0 = Offset1 - Offset0,
+ Size1 = Offset2 - Offset1,
+ Size2 = Offset3 - Offset2,
Size3 = QFreeListDefaultConstants::MaxIndex - Offset3
};
diff --git a/src/corelib/tools/qfreelist_p.h b/src/corelib/tools/qfreelist_p.h
index c49473802a..a90cb14cf5 100644
--- a/src/corelib/tools/qfreelist_p.h
+++ b/src/corelib/tools/qfreelist_p.h
@@ -56,7 +56,6 @@
QT_BEGIN_NAMESPACE
-
/*! \internal
Element in a QFreeList. ConstReferenceType and ReferenceType are used as
@@ -251,7 +250,7 @@ inline int QFreeList<T, ConstantsType>::next()
v = allocate((id & ConstantsType::IndexMask) - at, ConstantsType::Sizes[block]);
if (!_v[block].testAndSetRelease(nullptr, v)) {
// race with another thread lost
- delete [] v;
+ delete[] v;
v = _v[block].loadAcquire();
Q_ASSERT(v != nullptr);
}
diff --git a/src/corelib/tools/qhash.h b/src/corelib/tools/qhash.h
index 046dbddb57..ced64233b7 100644
--- a/src/corelib/tools/qhash.h
+++ b/src/corelib/tools/qhash.h
@@ -59,11 +59,10 @@ struct QHashDummyValue
namespace QHashPrivate {
// QHash uses a power of two growth policy.
-namespace GrowthPolicy
-{
+namespace GrowthPolicy {
inline constexpr size_t maxNumBuckets() noexcept
{
- return size_t(1) << (8*sizeof(size_t) - 1);
+ return size_t(1) << (8 * sizeof(size_t) - 1);
}
inline constexpr size_t bucketsForCapacity(size_t requestedCapacity) noexcept
{
@@ -71,7 +70,7 @@ inline constexpr size_t bucketsForCapacity(size_t requestedCapacity) noexcept
return 16;
if (requestedCapacity >= maxNumBuckets())
return maxNumBuckets();
- return qNextPowerOfTwo(QIntegerForSize<sizeof(size_t)>::Unsigned(2*requestedCapacity - 1));
+ return qNextPowerOfTwo(QIntegerForSize<sizeof(size_t)>::Unsigned(2 * requestedCapacity - 1));
}
inline constexpr size_t bucketForHash(size_t nBuckets, size_t hash) noexcept
{
@@ -282,7 +281,7 @@ struct Span {
entries[o].node().~Node();
}
}
- delete [] entries;
+ delete[] entries;
entries = nullptr;
}
}
@@ -387,14 +386,14 @@ struct Span {
// in here. The likelihood of having below 16 entries is very small,
// so start with that and increment by 16 each time we need to add
// some more space
- const size_t increment = NEntries/8;
+ const size_t increment = NEntries / 8;
size_t alloc = allocated + increment;
Entry *newEntries = new Entry[alloc];
// we only add storage if the previous storage was fully filled, so
// simply copy the old data over
if constexpr (isRelocatable<Node>()) {
if (allocated)
- memcpy(newEntries, entries, allocated*sizeof(Entry));
+ memcpy(newEntries, entries, allocated * sizeof(Entry));
} else {
for (size_t i = 0; i < allocated; ++i) {
new (&newEntries[i].node()) Node(std::move(entries[i].node()));
@@ -404,7 +403,7 @@ struct Span {
for (size_t i = allocated; i < allocated + increment; ++i) {
newEntries[i].nextFree() = uchar(i + 1);
}
- delete [] entries;
+ delete[] entries;
entries = newEntries;
allocated = uchar(alloc);
}
@@ -471,10 +470,9 @@ struct Data
return dd;
}
-
void clear()
{
- delete [] spans;
+ delete[] spans;
spans = nullptr;
size = 0;
numBuckets = 0;
@@ -524,7 +522,7 @@ struct Data
}
span.freeData();
}
- delete [] oldSpans;
+ delete[] oldSpans;
}
size_t nextBucket(size_t bucket) const noexcept
@@ -579,7 +577,8 @@ struct Data
return it.node();
}
- struct InsertionResult {
+ struct InsertionResult
+ {
iterator it;
bool initialized;
};
@@ -1144,7 +1143,7 @@ class QMultiHash
using Data = QHashPrivate::Data<Node>;
using Chain = QHashPrivate::MultiNodeChain<T>;
- Data *d = nullptr;
+ Data *d = nullptr;
qsizetype m_size = 0;
public:
diff --git a/src/corelib/tools/qhashfunctions.h b/src/corelib/tools/qhashfunctions.h
index 94c6e13b1c..9cfa852ba2 100644
--- a/src/corelib/tools/qhashfunctions.h
+++ b/src/corelib/tools/qhashfunctions.h
@@ -172,7 +172,8 @@ template<typename T> inline size_t qHash(const T &t, size_t seed)
namespace QtPrivate {
-struct QHashCombine {
+struct QHashCombine
+{
typedef size_t result_type;
template <typename T>
constexpr result_type operator()(size_t seed, const T &t) const noexcept(noexcept(qHash(t)))
@@ -180,7 +181,8 @@ struct QHashCombine {
{ return seed ^ (qHash(t) + 0x9e3779b9 + (seed << 6) + (seed >> 2)) ; }
};
-struct QHashCombineCommutative {
+struct QHashCombineCommutative
+{
// QHashCombine is a good hash combiner, but is not commutative,
// ie. it depends on the order of the input elements. That is
// usually what we want: {0,1,3} should hash differently than
diff --git a/src/corelib/tools/qiterator.h b/src/corelib/tools/qiterator.h
index c315b77c85..16c2d7f07c 100644
--- a/src/corelib/tools/qiterator.h
+++ b/src/corelib/tools/qiterator.h
@@ -205,20 +205,17 @@ public:
return std::pair<Key, T>(i.key(), i.value());
}
- struct pointer {
- pointer(value_type&& r_)
- : r(std::move(r_))
- {}
+ struct pointer
+ {
+ pointer(value_type &&r_) : r(std::move(r_)) { }
pointer() = default;
pointer(const pointer &other) = default;
pointer(pointer &&other) = default;
- pointer& operator=(const pointer &other) = default;
- pointer& operator=(pointer &&other) = default;
+ pointer &operator=(const pointer &other) = default;
+ pointer &operator=(pointer &&other) = default;
- value_type& operator*() const {
- return r;
- }
+ value_type &operator*() const { return r; }
value_type r;
const value_type *operator->() const {
diff --git a/src/corelib/tools/qlist.h b/src/corelib/tools/qlist.h
index c7b96a59d6..fe16bd6e94 100644
--- a/src/corelib/tools/qlist.h
+++ b/src/corelib/tools/qlist.h
@@ -692,7 +692,7 @@ template <typename ...Args>
typename QList<T>::iterator
QList<T>::emplace(qsizetype i, Args&&... args)
{
- Q_ASSERT_X(i >= 0 && i <= d->size, "QList<T>::insert", "index out of range");
+ Q_ASSERT_X(i >= 0 && i <= d->size, "QList<T>::insert", "index out of range");
const bool shouldGrow = d->shouldGrowBeforeInsert(d.begin() + i, 1);
const auto newSize = size() + 1;
diff --git a/src/corelib/tools/qmakearray_p.h b/src/corelib/tools/qmakearray_p.h
index 71441c2c27..4ed8c16234 100644
--- a/src/corelib/tools/qmakearray_p.h
+++ b/src/corelib/tools/qmakearray_p.h
@@ -61,17 +61,17 @@ QT_BEGIN_NAMESPACE
namespace QtPrivate {
template<typename T>
-constexpr T&& Forward(typename std::remove_reference<T>::type& t) noexcept
+constexpr T &&Forward(typename std::remove_reference<T>::type &t) noexcept
{
- return static_cast<T&&>(t);
+ return static_cast<T &&>(t);
}
template<typename T>
-constexpr T&& Forward(typename std::remove_reference<T>::type&& t) noexcept
+constexpr T &&Forward(typename std::remove_reference<T>::type &&t) noexcept
{
static_assert(!std::is_lvalue_reference<T>::value,
"template argument substituting T is an lvalue reference type");
- return static_cast<T&&>(t);
+ return static_cast<T &&>(t);
}
template <typename ManualType, typename ...>
diff --git a/src/corelib/tools/qpoint.h b/src/corelib/tools/qpoint.h
index dd0f177fa6..22208e139d 100644
--- a/src/corelib/tools/qpoint.h
+++ b/src/corelib/tools/qpoint.h
@@ -48,7 +48,6 @@ struct CGPoint;
QT_BEGIN_NAMESPACE
-
class QPoint
{
public:
@@ -67,7 +66,7 @@ public:
constexpr QPoint transposed() const noexcept { return {yp, xp}; }
constexpr inline int &rx() noexcept;
- constexpr inline int &ry()noexcept;
+ constexpr inline int &ry() noexcept;
constexpr inline QPoint &operator+=(const QPoint &p);
constexpr inline QPoint &operator-=(const QPoint &p);
@@ -124,90 +123,150 @@ constexpr inline QPoint::QPoint() noexcept : xp(0), yp(0) {}
constexpr inline QPoint::QPoint(int xpos, int ypos) noexcept : xp(xpos), yp(ypos) {}
constexpr inline bool QPoint::isNull() const noexcept
-{ return xp == 0 && yp == 0; }
+{
+ return xp == 0 && yp == 0;
+}
constexpr inline int QPoint::x() const noexcept
-{ return xp; }
+{
+ return xp;
+}
constexpr inline int QPoint::y() const noexcept
-{ return yp; }
+{
+ return yp;
+}
constexpr inline void QPoint::setX(int xpos) noexcept
-{ xp = xpos; }
+{
+ xp = xpos;
+}
constexpr inline void QPoint::setY(int ypos) noexcept
-{ yp = ypos; }
+{
+ yp = ypos;
+}
inline int constexpr QPoint::manhattanLength() const
-{ return qAbs(x())+qAbs(y()); }
+{
+ return qAbs(x()) + qAbs(y());
+}
constexpr inline int &QPoint::rx() noexcept
-{ return xp; }
+{
+ return xp;
+}
constexpr inline int &QPoint::ry() noexcept
-{ return yp; }
+{
+ return yp;
+}
constexpr inline QPoint &QPoint::operator+=(const QPoint &p)
-{ xp+=p.xp; yp+=p.yp; return *this; }
+{
+ xp += p.xp;
+ yp += p.yp;
+ return *this;
+}
constexpr inline QPoint &QPoint::operator-=(const QPoint &p)
-{ xp-=p.xp; yp-=p.yp; return *this; }
+{
+ xp -= p.xp;
+ yp -= p.yp;
+ return *this;
+}
constexpr inline QPoint &QPoint::operator*=(float factor)
-{ xp = qRound(xp*factor); yp = qRound(yp*factor); return *this; }
+{
+ xp = qRound(xp * factor);
+ yp = qRound(yp * factor);
+ return *this;
+}
constexpr inline QPoint &QPoint::operator*=(double factor)
-{ xp = qRound(xp*factor); yp = qRound(yp*factor); return *this; }
+{
+ xp = qRound(xp * factor);
+ yp = qRound(yp * factor);
+ return *this;
+}
constexpr inline QPoint &QPoint::operator*=(int factor)
-{ xp = xp*factor; yp = yp*factor; return *this; }
+{
+ xp = xp * factor;
+ yp = yp * factor;
+ return *this;
+}
constexpr inline bool operator==(const QPoint &p1, const QPoint &p2) noexcept
-{ return p1.xp == p2.xp && p1.yp == p2.yp; }
+{
+ return p1.xp == p2.xp && p1.yp == p2.yp;
+}
constexpr inline bool operator!=(const QPoint &p1, const QPoint &p2) noexcept
-{ return p1.xp != p2.xp || p1.yp != p2.yp; }
+{
+ return p1.xp != p2.xp || p1.yp != p2.yp;
+}
constexpr inline const QPoint operator+(const QPoint &p1, const QPoint &p2)
-{ return QPoint(p1.xp+p2.xp, p1.yp+p2.yp); }
+{
+ return QPoint(p1.xp + p2.xp, p1.yp + p2.yp);
+}
constexpr inline const QPoint operator-(const QPoint &p1, const QPoint &p2)
-{ return QPoint(p1.xp-p2.xp, p1.yp-p2.yp); }
+{
+ return QPoint(p1.xp - p2.xp, p1.yp - p2.yp);
+}
constexpr inline const QPoint operator*(const QPoint &p, float factor)
-{ return QPoint(qRound(p.xp*factor), qRound(p.yp*factor)); }
+{
+ return QPoint(qRound(p.xp * factor), qRound(p.yp * factor));
+}
constexpr inline const QPoint operator*(const QPoint &p, double factor)
-{ return QPoint(qRound(p.xp*factor), qRound(p.yp*factor)); }
+{
+ return QPoint(qRound(p.xp * factor), qRound(p.yp * factor));
+}
constexpr inline const QPoint operator*(const QPoint &p, int factor)
-{ return QPoint(p.xp*factor, p.yp*factor); }
+{
+ return QPoint(p.xp * factor, p.yp * factor);
+}
constexpr inline const QPoint operator*(float factor, const QPoint &p)
-{ return QPoint(qRound(p.xp*factor), qRound(p.yp*factor)); }
+{
+ return QPoint(qRound(p.xp * factor), qRound(p.yp * factor));
+}
constexpr inline const QPoint operator*(double factor, const QPoint &p)
-{ return QPoint(qRound(p.xp*factor), qRound(p.yp*factor)); }
+{
+ return QPoint(qRound(p.xp * factor), qRound(p.yp * factor));
+}
constexpr inline const QPoint operator*(int factor, const QPoint &p)
-{ return QPoint(p.xp*factor, p.yp*factor); }
+{
+ return QPoint(p.xp * factor, p.yp * factor);
+}
constexpr inline const QPoint operator+(const QPoint &p)
-{ return p; }
+{
+ return p;
+}
constexpr inline const QPoint operator-(const QPoint &p)
-{ return QPoint(-p.xp, -p.yp); }
+{
+ return QPoint(-p.xp, -p.yp);
+}
constexpr inline QPoint &QPoint::operator/=(qreal c)
{
- xp = qRound(xp/c);
- yp = qRound(yp/c);
+ xp = qRound(xp / c);
+ yp = qRound(yp / c);
return *this;
}
constexpr inline const QPoint operator/(const QPoint &p, qreal c)
{
- return QPoint(qRound(p.xp/c), qRound(p.yp/c));
+ return QPoint(qRound(p.xp / c), qRound(p.yp / c));
}
#ifndef QT_NO_DEBUG_STREAM
@@ -246,7 +305,9 @@ public:
constexpr inline QPointF &operator/=(qreal c);
constexpr static inline qreal dotProduct(const QPointF &p1, const QPointF &p2)
- { return p1.xp * p2.xp + p1.yp * p2.yp; }
+ {
+ return p1.xp * p2.xp + p1.yp * p2.yp;
+ }
friend constexpr inline bool operator==(const QPointF &, const QPointF &);
friend constexpr inline bool operator!=(const QPointF &, const QPointF &);
@@ -294,7 +355,7 @@ constexpr inline QPointF::QPointF(const QPoint &p) noexcept : xp(p.x()), yp(p.y(
constexpr inline qreal QPointF::manhattanLength() const
{
- return qAbs(x())+qAbs(y());
+ return qAbs(x()) + qAbs(y());
}
inline bool QPointF::isNull() const noexcept
@@ -334,19 +395,23 @@ constexpr inline qreal &QPointF::ry() noexcept
constexpr inline QPointF &QPointF::operator+=(const QPointF &p)
{
- xp+=p.xp;
- yp+=p.yp;
+ xp += p.xp;
+ yp += p.yp;
return *this;
}
constexpr inline QPointF &QPointF::operator-=(const QPointF &p)
{
- xp-=p.xp; yp-=p.yp; return *this;
+ xp -= p.xp;
+ yp -= p.yp;
+ return *this;
}
constexpr inline QPointF &QPointF::operator*=(qreal c)
{
- xp*=c; yp*=c; return *this;
+ xp *= c;
+ yp *= c;
+ return *this;
}
QT_WARNING_PUSH
@@ -367,22 +432,22 @@ QT_WARNING_POP
constexpr inline const QPointF operator+(const QPointF &p1, const QPointF &p2)
{
- return QPointF(p1.xp+p2.xp, p1.yp+p2.yp);
+ return QPointF(p1.xp + p2.xp, p1.yp + p2.yp);
}
constexpr inline const QPointF operator-(const QPointF &p1, const QPointF &p2)
{
- return QPointF(p1.xp-p2.xp, p1.yp-p2.yp);
+ return QPointF(p1.xp - p2.xp, p1.yp - p2.yp);
}
constexpr inline const QPointF operator*(const QPointF &p, qreal c)
{
- return QPointF(p.xp*c, p.yp*c);
+ return QPointF(p.xp * c, p.yp * c);
}
constexpr inline const QPointF operator*(qreal c, const QPointF &p)
{
- return QPointF(p.xp*c, p.yp*c);
+ return QPointF(p.xp * c, p.yp * c);
}
constexpr inline const QPointF operator+(const QPointF &p)
@@ -397,14 +462,14 @@ constexpr inline const QPointF operator-(const QPointF &p)
constexpr inline QPointF &QPointF::operator/=(qreal divisor)
{
- xp/=divisor;
- yp/=divisor;
+ xp /= divisor;
+ yp /= divisor;
return *this;
}
constexpr inline const QPointF operator/(const QPointF &p, qreal divisor)
{
- return QPointF(p.xp/divisor, p.yp/divisor);
+ return QPointF(p.xp / divisor, p.yp / divisor);
}
constexpr inline QPoint QPointF::toPoint() const
diff --git a/src/corelib/tools/qrect.h b/src/corelib/tools/qrect.h
index 3e7b965829..b898696293 100644
--- a/src/corelib/tools/qrect.h
+++ b/src/corelib/tools/qrect.h
@@ -130,11 +130,11 @@ public:
QRect operator|(const QRect &r) const noexcept;
QRect operator&(const QRect &r) const noexcept;
- inline QRect& operator|=(const QRect &r) noexcept;
- inline QRect& operator&=(const QRect &r) noexcept;
+ inline QRect &operator|=(const QRect &r) noexcept;
+ inline QRect &operator&=(const QRect &r) noexcept;
bool contains(const QRect &r, bool proper = false) const noexcept;
- bool contains(const QPoint &p, bool proper=false) const noexcept;
+ bool contains(const QPoint &p, bool proper = false) const noexcept;
inline bool contains(int x, int y) const noexcept;
inline bool contains(int x, int y, bool proper) const noexcept;
[[nodiscard]] inline QRect united(const QRect &other) const noexcept;
@@ -428,13 +428,13 @@ inline bool QRect::contains(int ax, int ay) const noexcept
return contains(QPoint(ax, ay), false);
}
-inline QRect& QRect::operator|=(const QRect &r) noexcept
+inline QRect &QRect::operator|=(const QRect &r) noexcept
{
*this = *this | r;
return *this;
}
-inline QRect& QRect::operator&=(const QRect &r) noexcept
+inline QRect &QRect::operator&=(const QRect &r) noexcept
{
*this = *this & r;
return *this;
@@ -596,8 +596,8 @@ public:
QRectF operator|(const QRectF &r) const noexcept;
QRectF operator&(const QRectF &r) const noexcept;
- inline QRectF& operator|=(const QRectF &r) noexcept;
- inline QRectF& operator&=(const QRectF &r) noexcept;
+ inline QRectF &operator|=(const QRectF &r) noexcept;
+ inline QRectF &operator&=(const QRectF &r) noexcept;
bool contains(const QRectF &r) const noexcept;
bool contains(const QPointF &p) const noexcept;
@@ -838,13 +838,13 @@ inline bool QRectF::contains(qreal ax, qreal ay) const noexcept
return contains(QPointF(ax, ay));
}
-inline QRectF& QRectF::operator|=(const QRectF &r) noexcept
+inline QRectF &QRectF::operator|=(const QRectF &r) noexcept
{
*this = *this | r;
return *this;
}
-inline QRectF& QRectF::operator&=(const QRectF &r) noexcept
+inline QRectF &QRectF::operator&=(const QRectF &r) noexcept
{
*this = *this & r;
return *this;
@@ -879,8 +879,8 @@ constexpr inline QRect QRectF::toRect() const noexcept
// All dimensions are at most off by 0.75, and topLeft by at most 0.5.
const int nxp = qRound(xp);
const int nyp = qRound(yp);
- const int nw = qRound(w + (xp - nxp)/2);
- const int nh = qRound(h + (yp - nyp)/2);
+ const int nw = qRound(w + (xp - nxp) / 2);
+ const int nh = qRound(h + (yp - nyp) / 2);
return QRect(nxp, nyp, nw, nh);
}
diff --git a/src/corelib/tools/qscopedpointer.h b/src/corelib/tools/qscopedpointer.h
index 4acec9c1f6..9f18e76c04 100644
--- a/src/corelib/tools/qscopedpointer.h
+++ b/src/corelib/tools/qscopedpointer.h
@@ -72,7 +72,7 @@ struct QScopedPointerArrayDeleter
typedef char IsIncompleteType[ sizeof(T) ? 1 : -1 ];
(void) sizeof(IsIncompleteType);
- delete [] pointer;
+ delete[] pointer;
}
};
@@ -240,7 +240,8 @@ public:
{ QScopedPointer<T, Cleanup>::swap(other); }
private:
- explicit inline QScopedArrayPointer(void *) {
+ explicit inline QScopedArrayPointer(void *)
+ {
// Enforce the same type.
// If you get a compile error here, make sure you declare
diff --git a/src/corelib/tools/qsharedpointer.h b/src/corelib/tools/qsharedpointer.h
index 5d47369687..82eb80beff 100644
--- a/src/corelib/tools/qsharedpointer.h
+++ b/src/corelib/tools/qsharedpointer.h
@@ -66,7 +66,7 @@ public:
operator bool() const;
bool operator!() const;
T &operator*() const;
- T *operator ->() const;
+ T *operator->() const;
// constructors
QSharedPointer();
diff --git a/src/corelib/tools/qsize.h b/src/corelib/tools/qsize.h
index d89d9e0426..05b3448c6d 100644
--- a/src/corelib/tools/qsize.h
+++ b/src/corelib/tools/qsize.h
@@ -127,13 +127,13 @@ constexpr inline QSize::QSize() noexcept : wd(-1), ht(-1) {}
constexpr inline QSize::QSize(int w, int h) noexcept : wd(w), ht(h) {}
constexpr inline bool QSize::isNull() const noexcept
-{ return wd==0 && ht==0; }
+{ return wd == 0 && ht == 0; }
constexpr inline bool QSize::isEmpty() const noexcept
-{ return wd<1 || ht<1; }
+{ return wd < 1 || ht < 1; }
constexpr inline bool QSize::isValid() const noexcept
-{ return wd>=0 && ht>=0; }
+{ return wd >= 0 && ht >= 0; }
constexpr inline int QSize::width() const noexcept
{ return wd; }
@@ -166,13 +166,25 @@ constexpr inline int &QSize::rheight() noexcept
{ return ht; }
constexpr inline QSize &QSize::operator+=(const QSize &s) noexcept
-{ wd+=s.wd; ht+=s.ht; return *this; }
+{
+ wd += s.wd;
+ ht += s.ht;
+ return *this;
+}
constexpr inline QSize &QSize::operator-=(const QSize &s) noexcept
-{ wd-=s.wd; ht-=s.ht; return *this; }
+{
+ wd -= s.wd;
+ ht -= s.ht;
+ return *this;
+}
constexpr inline QSize &QSize::operator*=(qreal c) noexcept
-{ wd = qRound(wd*c); ht = qRound(ht*c); return *this; }
+{
+ wd = qRound(wd * c);
+ ht = qRound(ht * c);
+ return *this;
+}
constexpr inline bool operator==(const QSize &s1, const QSize &s2) noexcept
{ return s1.wd == s2.wd && s1.ht == s2.ht; }
@@ -183,29 +195,38 @@ constexpr inline bool operator!=(const QSize &s1, const QSize &s2) noexcept
constexpr inline size_t qHash(const QSize &s, size_t seed = 0) noexcept
{ return qHashMulti(seed, s.wd, s.ht); }
-constexpr inline const QSize operator+(const QSize & s1, const QSize & s2) noexcept
-{ return QSize(s1.wd+s2.wd, s1.ht+s2.ht); }
+constexpr inline const QSize operator+(const QSize &s1, const QSize &s2) noexcept
+{
+ return QSize(s1.wd + s2.wd, s1.ht + s2.ht);
+}
constexpr inline const QSize operator-(const QSize &s1, const QSize &s2) noexcept
-{ return QSize(s1.wd-s2.wd, s1.ht-s2.ht); }
+{
+ return QSize(s1.wd - s2.wd, s1.ht - s2.ht);
+}
constexpr inline const QSize operator*(const QSize &s, qreal c) noexcept
-{ return QSize(qRound(s.wd*c), qRound(s.ht*c)); }
+{
+ return QSize(qRound(s.wd * c), qRound(s.ht * c));
+}
constexpr inline const QSize operator*(qreal c, const QSize &s) noexcept
-{ return QSize(qRound(s.wd*c), qRound(s.ht*c)); }
+{
+ return QSize(qRound(s.wd * c), qRound(s.ht * c));
+}
inline QSize &QSize::operator/=(qreal c)
{
Q_ASSERT(!qFuzzyIsNull(c));
- wd = qRound(wd/c); ht = qRound(ht/c);
+ wd = qRound(wd / c);
+ ht = qRound(ht / c);
return *this;
}
inline const QSize operator/(const QSize &s, qreal c)
{
Q_ASSERT(!qFuzzyIsNull(c));
- return QSize(qRound(s.wd/c), qRound(s.ht/c));
+ return QSize(qRound(s.wd / c), qRound(s.ht / c));
}
constexpr inline QSize QSize::expandedTo(const QSize & otherSize) const noexcept
@@ -344,13 +365,25 @@ constexpr inline qreal &QSizeF::rheight() noexcept
{ return ht; }
constexpr inline QSizeF &QSizeF::operator+=(const QSizeF &s) noexcept
-{ wd += s.wd; ht += s.ht; return *this; }
+{
+ wd += s.wd;
+ ht += s.ht;
+ return *this;
+}
constexpr inline QSizeF &QSizeF::operator-=(const QSizeF &s) noexcept
-{ wd -= s.wd; ht -= s.ht; return *this; }
+{
+ wd -= s.wd;
+ ht -= s.ht;
+ return *this;
+}
constexpr inline QSizeF &QSizeF::operator*=(qreal c) noexcept
-{ wd *= c; ht *= c; return *this; }
+{
+ wd *= c;
+ ht *= c;
+ return *this;
+}
constexpr inline bool operator==(const QSizeF &s1, const QSizeF &s2) noexcept
{ return qFuzzyCompare(s1.wd, s2.wd) && qFuzzyCompare(s1.ht, s2.ht); }
@@ -358,39 +391,48 @@ constexpr inline bool operator==(const QSizeF &s1, const QSizeF &s2) noexcept
constexpr inline bool operator!=(const QSizeF &s1, const QSizeF &s2) noexcept
{ return !qFuzzyCompare(s1.wd, s2.wd) || !qFuzzyCompare(s1.ht, s2.ht); }
-constexpr inline const QSizeF operator+(const QSizeF & s1, const QSizeF & s2) noexcept
-{ return QSizeF(s1.wd+s2.wd, s1.ht+s2.ht); }
+constexpr inline const QSizeF operator+(const QSizeF &s1, const QSizeF &s2) noexcept
+{
+ return QSizeF(s1.wd + s2.wd, s1.ht + s2.ht);
+}
constexpr inline const QSizeF operator-(const QSizeF &s1, const QSizeF &s2) noexcept
-{ return QSizeF(s1.wd-s2.wd, s1.ht-s2.ht); }
+{
+ return QSizeF(s1.wd - s2.wd, s1.ht - s2.ht);
+}
constexpr inline const QSizeF operator*(const QSizeF &s, qreal c) noexcept
-{ return QSizeF(s.wd*c, s.ht*c); }
+{
+ return QSizeF(s.wd * c, s.ht * c);
+}
constexpr inline const QSizeF operator*(qreal c, const QSizeF &s) noexcept
-{ return QSizeF(s.wd*c, s.ht*c); }
+{
+ return QSizeF(s.wd * c, s.ht * c);
+}
inline QSizeF &QSizeF::operator/=(qreal c)
{
Q_ASSERT(!qFuzzyIsNull(c));
- wd = wd/c; ht = ht/c;
+ wd = wd / c;
+ ht = ht / c;
return *this;
}
inline const QSizeF operator/(const QSizeF &s, qreal c)
{
Q_ASSERT(!qFuzzyIsNull(c));
- return QSizeF(s.wd/c, s.ht/c);
+ return QSizeF(s.wd / c, s.ht / c);
}
-constexpr inline QSizeF QSizeF::expandedTo(const QSizeF & otherSize) const noexcept
+constexpr inline QSizeF QSizeF::expandedTo(const QSizeF &otherSize) const noexcept
{
- return QSizeF(qMax(wd,otherSize.wd), qMax(ht,otherSize.ht));
+ return QSizeF(qMax(wd, otherSize.wd), qMax(ht, otherSize.ht));
}
-constexpr inline QSizeF QSizeF::boundedTo(const QSizeF & otherSize) const noexcept
+constexpr inline QSizeF QSizeF::boundedTo(const QSizeF &otherSize) const noexcept
{
- return QSizeF(qMin(wd,otherSize.wd), qMin(ht,otherSize.ht));
+ return QSizeF(qMin(wd, otherSize.wd), qMin(ht, otherSize.ht));
}
constexpr inline QSize QSizeF::toSize() const noexcept
diff --git a/src/corelib/tools/qtimeline.cpp b/src/corelib/tools/qtimeline.cpp
index f8e78170c4..4609b258fc 100644
--- a/src/corelib/tools/qtimeline.cpp
+++ b/src/corelib/tools/qtimeline.cpp
@@ -96,7 +96,7 @@ void QTimeLinePrivate::setCurrentTime(int msecs)
int lastFrame = q->currentFrame();
// Determine if we are looping.
- int elapsed = (direction == QTimeLine::Backward) ? (-msecs + duration) : msecs;
+ int elapsed = (direction == QTimeLine::Backward) ? (-msecs + duration) : msecs;
int loopCount = elapsed / duration;
bool looping = (loopCount != currentLoopCount);
@@ -490,7 +490,7 @@ QEasingCurve QTimeLine::easingCurve() const
return d->easingCurve;
}
-void QTimeLine::setEasingCurve(const QEasingCurve& curve)
+void QTimeLine::setEasingCurve(const QEasingCurve &curve)
{
Q_D(QTimeLine);
d->easingCurve = curve;
diff --git a/src/corelib/tools/qtools_p.h b/src/corelib/tools/qtools_p.h
index 5b6be12820..8854ae8c48 100644
--- a/src/corelib/tools/qtools_p.h
+++ b/src/corelib/tools/qtools_p.h
@@ -89,7 +89,8 @@ constexpr inline int fromOct(uint c) noexcept
// We typically need an extra bit for qNextPowerOfTwo when determining the next allocation size.
constexpr qsizetype MaxAllocSize = (std::numeric_limits<qsizetype>::max)();
-struct CalculateGrowingBlockSizeResult {
+struct CalculateGrowingBlockSizeResult
+{
qsizetype size;
qsizetype elementCount;
};
diff --git a/src/corelib/tools/qvarlengtharray.h b/src/corelib/tools/qvarlengtharray.h
index a3a07887d3..d7e1941539 100644
--- a/src/corelib/tools/qvarlengtharray.h
+++ b/src/corelib/tools/qvarlengtharray.h
@@ -104,7 +104,8 @@ public:
std::copy(first, last, std::back_inserter(*this));
}
- inline ~QVarLengthArray() {
+ inline ~QVarLengthArray()
+ {
if (QTypeInfo<T>::isComplex) {
T *i = ptr + s;
while (i-- != ptr)
@@ -130,7 +131,7 @@ public:
// the moved-from state is the empty state, so we're good with the clear() here:
clear();
Q_ASSERT(capacity() >= Prealloc);
- const auto otherInlineStorage = reinterpret_cast<T*>(other.array);
+ const auto otherInlineStorage = reinterpret_cast<T *>(other.array);
if (other.ptr != otherInlineStorage) {
// heap storage: steal the external buffer, reset other to otherInlineStorage
a = std::exchange(other.a, Prealloc);
@@ -151,7 +152,8 @@ public:
return *this;
}
- inline void removeLast() {
+ inline void removeLast()
+ {
Q_ASSERT(s > 0);
if (QTypeInfo<T>::isComplex)
ptr[s - 1].~T();
@@ -160,10 +162,26 @@ public:
inline qsizetype size() const { return s; }
inline qsizetype count() const { return s; }
inline qsizetype length() const { return s; }
- inline T& first() { Q_ASSERT(!isEmpty()); return *begin(); }
- inline const T& first() const { Q_ASSERT(!isEmpty()); return *begin(); }
- T& last() { Q_ASSERT(!isEmpty()); return *(end() - 1); }
- const T& last() const { Q_ASSERT(!isEmpty()); return *(end() - 1); }
+ inline T &first()
+ {
+ Q_ASSERT(!isEmpty());
+ return *begin();
+ }
+ inline const T &first() const
+ {
+ Q_ASSERT(!isEmpty());
+ return *begin();
+ }
+ T &last()
+ {
+ Q_ASSERT(!isEmpty());
+ return *(end() - 1);
+ }
+ const T &last() const
+ {
+ Q_ASSERT(!isEmpty());
+ return *(end() - 1);
+ }
inline bool isEmpty() const { return (s == 0); }
inline void resize(qsizetype size);
inline void clear() { resize(0); }
@@ -179,11 +197,13 @@ public:
template <typename AT>
inline bool contains(const AT &t) const;
- inline T &operator[](qsizetype idx) {
+ inline T &operator[](qsizetype idx)
+ {
Q_ASSERT(idx >= 0 && idx < s);
return ptr[idx];
}
- inline const T &operator[](qsizetype idx) const {
+ inline const T &operator[](qsizetype idx) const
+ {
Q_ASSERT(idx >= 0 && idx < s);
return ptr[idx];
}
@@ -192,8 +212,9 @@ public:
T value(qsizetype i) const;
T value(qsizetype i, const T &defaultValue) const;
- inline void append(const T &t) {
- if (s == a) { // i.e. s != 0
+ inline void append(const T &t)
+ {
+ if (s == a) { // i.e. s != 0
T copy(t);
reallocate(s, s << 1);
const qsizetype idx = s++;
@@ -212,7 +233,8 @@ public:
}
}
- void append(T &&t) {
+ void append(T &&t)
+ {
if (s == a)
reallocate(s, s << 1);
const qsizetype idx = s++;
@@ -241,10 +263,9 @@ public:
void remove(qsizetype i);
void remove(qsizetype i, qsizetype n);
-
inline T *data() { return ptr; }
inline const T *data() const { return ptr; }
- inline const T * constData() const { return ptr; }
+ inline const T *constData() const { return ptr; }
typedef qsizetype size_type;
typedef T value_type;
typedef value_type *pointer;
@@ -253,9 +274,8 @@ public:
typedef const value_type &const_reference;
typedef qptrdiff difference_type;
-
- typedef T* iterator;
- typedef const T* const_iterator;
+ typedef T *iterator;
+ typedef const T *const_iterator;
typedef std::reverse_iterator<iterator> reverse_iterator;
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
@@ -277,7 +297,7 @@ public:
iterator insert(const_iterator before, T &&x);
inline iterator insert(const_iterator before, const T &x) { return insert(before, 1, x); }
iterator erase(const_iterator begin, const_iterator end);
- inline iterator erase(const_iterator pos) { return erase(pos, pos+1); }
+ inline iterator erase(const_iterator pos) { return erase(pos, pos + 1); }
// STL compatibility:
inline bool empty() const { return isEmpty(); }
@@ -300,7 +320,7 @@ private:
bool isValidIterator(const const_iterator &i) const
{
- const std::less<const T*> less = {};
+ const std::less<const T *> less = {};
return !less(cend(), i) && !less(i, cbegin());
}
};
@@ -425,7 +445,7 @@ Q_OUTOFLINE_TEMPLATE void QVarLengthArray<T, Prealloc>::reallocate(qsizetype asi
Q_ASSUME(copySize >= 0);
if (aalloc != a) {
if (aalloc > Prealloc) {
- T* newPtr = reinterpret_cast<T *>(malloc(aalloc * sizeof(T)));
+ T *newPtr = reinterpret_cast<T *>(malloc(aalloc * sizeof(T)));
Q_CHECK_PTR(newPtr); // could throw
// by design: in case of QT_NO_EXCEPTIONS malloc must not fail or it crashes here
ptr = newPtr;
diff --git a/src/corelib/tools/qversionnumber.cpp b/src/corelib/tools/qversionnumber.cpp
index 517f026547..f91fa20043 100644
--- a/src/corelib/tools/qversionnumber.cpp
+++ b/src/corelib/tools/qversionnumber.cpp
@@ -698,7 +698,7 @@ size_t qHash(const QVersionNumber &key, size_t seed)
Writes the revision \a revision to stream \a out.
*/
-QDataStream& operator<<(QDataStream &out, const QTypeRevision &revision)
+QDataStream &operator<<(QDataStream &out, const QTypeRevision &revision)
{
return out << revision.toEncodedVersion<quint16>();
}
@@ -710,7 +710,7 @@ QDataStream& operator<<(QDataStream &out, const QTypeRevision &revision)
Reads a revision from stream \a in and stores it in \a revision.
*/
-QDataStream& operator>>(QDataStream &in, QTypeRevision &revision)
+QDataStream &operator>>(QDataStream &in, QTypeRevision &revision)
{
quint16 value;
in >> value;
diff --git a/src/corelib/tools/qversionnumber.h b/src/corelib/tools/qversionnumber.h
index e1d979f000..392efc7462 100644
--- a/src/corelib/tools/qversionnumber.h
+++ b/src/corelib/tools/qversionnumber.h
@@ -55,8 +55,8 @@ class QVersionNumber;
Q_CORE_EXPORT size_t qHash(const QVersionNumber &key, size_t seed = 0);
#ifndef QT_NO_DATASTREAM
-Q_CORE_EXPORT QDataStream& operator<<(QDataStream &out, const QVersionNumber &version);
-Q_CORE_EXPORT QDataStream& operator>>(QDataStream &in, QVersionNumber &version);
+Q_CORE_EXPORT QDataStream &operator<<(QDataStream &out, const QVersionNumber &version);
+Q_CORE_EXPORT QDataStream &operator>>(QDataStream &in, QVersionNumber &version);
#endif
class QVersionNumber
@@ -71,19 +71,20 @@ class QVersionNumber
enum {
// in little-endian, inline_segments[0] is shared with the pointer's LSB, while
// in big-endian, it's inline_segments[7]
- InlineSegmentMarker = Q_BYTE_ORDER == Q_LITTLE_ENDIAN ? 0 : sizeof(void*) - 1,
+ InlineSegmentMarker = Q_BYTE_ORDER == Q_LITTLE_ENDIAN ? 0 : sizeof(void *) - 1,
InlineSegmentStartIdx = !InlineSegmentMarker, // 0 for BE, 1 for LE
- InlineSegmentCount = sizeof(void*) - 1
+ InlineSegmentCount = sizeof(void *) - 1
};
static_assert(InlineSegmentCount >= 3); // at least major, minor, micro
- struct SegmentStorage {
+ struct SegmentStorage
+ {
// Note: we alias the use of dummy and inline_segments in the use of the
// union below. This is undefined behavior in C++98, but most compilers implement
// the C++11 behavior. The one known exception is older versions of Sun Studio.
union {
quintptr dummy;
- qint8 inline_segments[sizeof(void*)];
+ qint8 inline_segments[sizeof(void *)];
QList<int> *pointer_segments;
};
@@ -463,4 +464,4 @@ QT_END_NAMESPACE
Q_DECLARE_METATYPE(QVersionNumber)
Q_DECLARE_METATYPE(QTypeRevision)
-#endif //QVERSIONNUMBER_H
+#endif // QVERSIONNUMBER_H