From d6f5721d4c0c890d1a719452bb5b9c4fc582508d Mon Sep 17 00:00:00 2001 From: Ivailo Monev Date: Thu, 23 May 2019 00:04:11 +0000 Subject: [PATCH] QVariant, QByteArrayMatcher, QListData and QString cleanup Signed-off-by: Ivailo Monev --- src/core/kernel/qvariant.h | 26 -------------------------- src/core/tools/qbytearraymatcher.h | 5 +---- src/core/tools/qlist.h | 2 +- src/core/tools/qstring.cpp | 4 ++-- src/core/tools/qstring.h | 3 +-- 5 files changed, 5 insertions(+), 35 deletions(-) diff --git a/src/core/kernel/qvariant.h b/src/core/kernel/qvariant.h index afcececaf..4f5c755c9 100644 --- a/src/core/kernel/qvariant.h +++ b/src/core/kernel/qvariant.h @@ -76,7 +76,6 @@ class QTextFormat; class QTextLength; class QUrl; class QVariant; -class QVariantComparisonHelper; class QDebug; template @@ -375,7 +374,6 @@ protected: friend inline bool qvariant_cast_helper(const QVariant &, QVariant::Type, void *); friend int qRegisterGuiVariant(); friend int qUnregisterGuiVariant(); - friend inline bool operator==(const QVariant &, const QVariantComparisonHelper &); #ifndef QT_NO_DEBUG_STREAM friend Q_CORE_EXPORT QDebug operator<<(QDebug, const QVariant &); #endif @@ -452,30 +450,6 @@ Q_CORE_EXPORT QDataStream& operator>> (QDataStream& s, QVariant::Type& p); Q_CORE_EXPORT QDataStream& operator<< (QDataStream& s, const QVariant::Type p); #endif - -/* Helper class to add one more level of indirection to prevent - implicit casts. -*/ -class QVariantComparisonHelper -{ -public: - inline QVariantComparisonHelper(const QVariant &var) - : v(&var) {} -private: - friend inline bool operator==(const QVariant &, const QVariantComparisonHelper &); - const QVariant *v; -}; - -inline bool operator==(const QVariant &v1, const QVariantComparisonHelper &v2) -{ - return v1.cmp(*v2.v); -} - -inline bool operator!=(const QVariant &v1, const QVariantComparisonHelper &v2) -{ - return !operator==(v1, v2); -} - #ifndef QT_MOC template inline T qvariant_cast(const QVariant &v) { diff --git a/src/core/tools/qbytearraymatcher.h b/src/core/tools/qbytearraymatcher.h index 68c5d5929..6b942bb54 100644 --- a/src/core/tools/qbytearraymatcher.h +++ b/src/core/tools/qbytearraymatcher.h @@ -80,10 +80,7 @@ private: const uchar *p; int l; }; - union { - uint dummy[256]; - Data p; - }; + Data p; }; QT_END_NAMESPACE diff --git a/src/core/tools/qlist.h b/src/core/tools/qlist.h index b16b6b967..7b36b57a3 100644 --- a/src/core/tools/qlist.h +++ b/src/core/tools/qlist.h @@ -68,7 +68,7 @@ struct Q_CORE_EXPORT QListData { struct Data { QAtomicInt ref; int alloc, begin, end; - uint sharable : 1; + bool sharable; void *array[1]; }; enum { DataHeaderSize = sizeof(Data) - sizeof(void *) }; diff --git a/src/core/tools/qstring.cpp b/src/core/tools/qstring.cpp index 87711492e..d71e3c3de 100644 --- a/src/core/tools/qstring.cpp +++ b/src/core/tools/qstring.cpp @@ -658,9 +658,9 @@ static int findChar(const QChar *str, int len, QChar ch, int from, */ QString::Data QString::shared_null = { QAtomicInt(1), - 0, 0, shared_null.array, 0, {0} }; + 0, 0, 0, shared_null.array, {0} }; QString::Data QString::shared_empty = { QAtomicInt(1), - 0, 0, shared_empty.array, 0, {0} }; + 0, 0, 0, shared_empty.array, {0} }; int QString::grow(int size) { diff --git a/src/core/tools/qstring.h b/src/core/tools/qstring.h index 3866b6371..bbf72517a 100644 --- a/src/core/tools/qstring.h +++ b/src/core/tools/qstring.h @@ -493,9 +493,8 @@ private: struct Data { QAtomicInt ref; - int alloc, size; + int alloc, size, capacity; ushort *data; - ushort capacity : 1; ushort array[1]; }; static Data shared_null;