Replace QByteArrayData class by typedef.
authorJędrzej Nowacki <jedrzej.nowacki@nokia.com>
Tue, 24 Apr 2012 10:25:07 +0000 (12:25 +0200)
committerQt by Nokia <qt-info@nokia.com>
Fri, 4 May 2012 15:57:46 +0000 (17:57 +0200)
QByteArrayData was binary compatible with QArrayData, but we do not
need a separate class, QArrayData should be sufficient. Preferably we
would use QTypedArrayData<char> but it is not POD, therefore it can
not be initialized with {} syntax.

Change-Id: I1edd7b4f236b06d8f2dbfd8a37a3f5699b6a2c07
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: João Abecasis <joao.abecasis@nokia.com>
Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
Reviewed-by: Robin Burchell <robin+qt@viroteck.net>
src/corelib/kernel/qobjectdefs.h
src/corelib/tools/qbytearray.h

index cc44245..9053e7e 100644 (file)
@@ -52,7 +52,8 @@ QT_BEGIN_NAMESPACE
 
 
 class QByteArray;
-struct QByteArrayData;
+class QArrayData;
+typedef QArrayData QByteArrayData;
 
 class QString;
 
index 0f5ebcf..6d4c155 100644 (file)
@@ -120,26 +120,7 @@ class QString;
 class QDataStream;
 template <typename T> class QList;
 
-struct QByteArrayData
-{
-    // Keep in sync with QArrayData
-
-    QtPrivate::RefCount ref;
-    int size;
-    uint alloc : 31;
-    uint capacityReserved : 1;
-
-    qptrdiff offset;
-
-    inline char *data() { return reinterpret_cast<char *>(this) + offset; }
-    inline const char *data() const { return reinterpret_cast<const char *>(this) + offset; }
-};
-
-Q_STATIC_ASSERT(sizeof(QArrayData) == sizeof(QByteArrayData));
-Q_STATIC_ASSERT(offsetof(QArrayData, ref) == offsetof(QByteArrayData, ref));
-Q_STATIC_ASSERT(offsetof(QArrayData, size) == offsetof(QByteArrayData, size));
-//  Can't use offsetof on bitfield members alloc, capacityReserved
-Q_STATIC_ASSERT(offsetof(QArrayData, offset) == offsetof(QByteArrayData, offset));
+typedef QArrayData QByteArrayData;
 
 template<int N> struct QStaticByteArrayData
 {