Whitespace cleanup in corelib/tools

Change-Id: Ibe796c398a8e5488b7203abb07aa54740744f1ab
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Allan Sandfeld Jensen 2020-10-20 12:19:21 +02:00
parent 9aba868571
commit 05685708b7
25 changed files with 349 additions and 220 deletions

View File

@ -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
*****************************************************************************/

View File

@ -44,7 +44,6 @@
QT_BEGIN_NAMESPACE
class QBitRef;
class Q_CORE_EXPORT QBitArray
{
@ -148,6 +147,7 @@ private:
qsizetype i;
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); }

View File

@ -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;

View File

@ -320,7 +320,8 @@ static bool isConfigFunction(QEasingCurve::Type type)
type == QEasingCurve::TCBSpline;
}
struct TCBPoint {
struct TCBPoint
{
QPointF _point;
qreal _t;
qreal _c;
@ -1202,9 +1203,9 @@ bool QEasingCurve::operator==(const QEasingCurve &other) const
} 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());
res = qFuzzyCompare(amplitude(), other.amplitude())
&& qFuzzyCompare(period(), other.period())
&& qFuzzyCompare(overshoot(), other.overshoot());
}
}
return res;

View File

@ -49,7 +49,6 @@ QT_REQUIRE_CONFIG(easingcurve);
QT_BEGIN_NAMESPACE
class QEasingCurvePrivate;
class QPointF;
class Q_CORE_EXPORT QEasingCurve
@ -108,6 +107,7 @@ public:
EasingFunction customType() const;
qreal valueForProgress(qreal progress) const;
private:
QEasingCurvePrivate *d_ptr;
#ifndef QT_NO_DEBUG_STREAM

View File

@ -56,7 +56,6 @@
QT_BEGIN_NAMESPACE
/*! \internal
Element in a QFreeList. ConstReferenceType and ReferenceType are used as

View File

@ -59,8 +59,7 @@ 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);
@ -471,7 +470,6 @@ struct Data
return dd;
}
void clear()
{
delete[] spans;
@ -579,7 +577,8 @@ struct Data
return it.node();
}
struct InsertionResult {
struct InsertionResult
{
iterator it;
bool initialized;
};

View File

@ -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

View File

@ -205,10 +205,9 @@ 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;
@ -216,9 +215,7 @@ public:
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 {

View File

@ -48,7 +48,6 @@ struct CGPoint;
QT_BEGIN_NAMESPACE
class QPoint
{
public:
@ -124,79 +123,139 @@ 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)
{
@ -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 &);
@ -341,12 +402,16 @@ constexpr inline QPointF &QPointF::operator+=(const QPointF &p)
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

View File

@ -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

View File

@ -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; }
@ -184,21 +196,30 @@ 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); }
{
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;
}
@ -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); }
@ -359,21 +392,30 @@ 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); }
{
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;
}

View File

@ -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;
};

View File

@ -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)
@ -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,7 +212,8 @@ public:
T value(qsizetype i) const;
T value(qsizetype i, const T &defaultValue) const;
inline void append(const T &t) {
inline void append(const T &t)
{
if (s == a) { // i.e. s != 0
T copy(t);
reallocate(s, s << 1);
@ -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,7 +263,6 @@ 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; }
@ -253,7 +274,6 @@ public:
typedef const value_type &const_reference;
typedef qptrdiff difference_type;
typedef T *iterator;
typedef const T *const_iterator;
typedef std::reverse_iterator<iterator> reverse_iterator;

View File

@ -77,7 +77,8 @@ class QVersionNumber
};
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.