diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2012-06-25 21:22:19 +0200 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2019-12-08 18:20:11 +0100 |
commit | eab6eb64d2fab21c4791738323ca7d670a907de1 (patch) | |
tree | 979fddf65029409db1adba51363b769066783ccf /src/corelib/tools | |
parent | 00fbc087dd54b31e97b1557766b037b00120c43f (diff) |
Final removal of the size and offset members from QArrayData
Those members are not required anymore and now part of the
object itself.
Change-Id: If9eb5355ca8f2cf9528f6f63ca4e172acc9f9aed
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/corelib/tools')
-rw-r--r-- | src/corelib/tools/qarraydata.cpp | 6 | ||||
-rw-r--r-- | src/corelib/tools/qarraydata.h | 49 |
2 files changed, 6 insertions, 49 deletions
diff --git a/src/corelib/tools/qarraydata.cpp b/src/corelib/tools/qarraydata.cpp index 8052c2ca69..9c3848fa7a 100644 --- a/src/corelib/tools/qarraydata.cpp +++ b/src/corelib/tools/qarraydata.cpp @@ -153,11 +153,11 @@ QT_WARNING_PUSH QT_WARNING_DISABLE_GCC("-Wmissing-field-initializers") const QArrayData QArrayData::shared_null[2] = { - { Q_BASIC_ATOMIC_INITIALIZER(-1), QArrayData::StaticDataFlags, 0, 0, sizeof(QArrayData) }, // shared null + { Q_BASIC_ATOMIC_INITIALIZER(-1), QArrayData::StaticDataFlags, 0 }, // shared null /* zero initialized terminator */}; static const QArrayData emptyNotNullShared[2] = { - { Q_BASIC_ATOMIC_INITIALIZER(-1), QArrayData::StaticDataFlags, 0, 0, sizeof(QArrayData) }, // shared empty + { Q_BASIC_ATOMIC_INITIALIZER(-1), QArrayData::StaticDataFlags, 0 }, // shared empty /* zero initialized terminator */}; QT_WARNING_POP @@ -185,7 +185,6 @@ static QArrayData *allocateData(size_t allocSize, uint options) if (header) { header->ref_.storeRelaxed(1); header->flags = options; - header->size = 0; } return header; } @@ -233,7 +232,6 @@ void *QArrayData::allocate(QArrayData **dptr, size_t objectSize, size_t alignmen // find where offset should point to so that data() is aligned to alignment bytes data = (quintptr(header) + sizeof(QArrayData) + alignment - 1) & ~(alignment - 1); - header->offset = data - quintptr(header); header->alloc = capacity; } diff --git a/src/corelib/tools/qarraydata.h b/src/corelib/tools/qarraydata.h index 6cf0ea1cb6..483f6d5edb 100644 --- a/src/corelib/tools/qarraydata.h +++ b/src/corelib/tools/qarraydata.h @@ -73,11 +73,8 @@ struct Q_CORE_EXPORT QArrayData QBasicAtomicInt ref_; uint flags; - int size; uint alloc; - qptrdiff offset; // in bytes from beginning of header - inline size_t allocatedCapacity() { return alloc; @@ -104,20 +101,6 @@ struct Q_CORE_EXPORT QArrayData return ref_.deref(); } - void *data() - { - Q_ASSERT(size == 0 - || offset < 0 || size_t(offset) >= sizeof(QArrayData)); - return reinterpret_cast<char *>(this) + offset; - } - - const void *data() const - { - Q_ASSERT(size == 0 - || offset < 0 || size_t(offset) >= sizeof(QArrayData)); - return reinterpret_cast<const char *>(this) + offset; - } - // This refers to array data mutability, not "header data" represented by // data members in QArrayData. Shared data (array and header) must still // follow COW principles. @@ -188,7 +171,6 @@ struct Q_CORE_EXPORT QArrayData static void *sharedNullData() { QArrayData *const null = const_cast<QArrayData *>(&shared_null[1]); - Q_ASSERT(sharedNull()->data() == null); return null; } }; @@ -292,16 +274,6 @@ struct QTypedArrayData typedef const T* const_iterator; #endif - T *data() { return static_cast<T *>(QArrayData::data()); } - const T *data() const { return static_cast<const T *>(QArrayData::data()); } - - iterator begin(iterator = iterator()) { return data(); } - iterator end(iterator = iterator()) { return data() + size; } - const_iterator begin(const_iterator = const_iterator()) const { return data(); } - const_iterator end(const_iterator = const_iterator()) const { return data() + size; } - const_iterator constBegin(const_iterator = const_iterator()) const { return data(); } - const_iterator constEnd(const_iterator = const_iterator()) const { return data() + size; } - class AlignmentDummy { QArrayData header; T data; }; Q_REQUIRED_RESULT static QPair<QTypedArrayData *, T *> allocate(size_t capacity, @@ -341,9 +313,6 @@ struct QTypedArrayData }; if (result.ptr) { Q_ASSERT(!result.ptr->isShared()); // No shared empty, please! - result.ptr->offset = reinterpret_cast<const char *>(data) - - reinterpret_cast<const char *>(result.ptr); - result.ptr->size = int(n); } return result; } @@ -367,15 +336,6 @@ struct QTypedArrayData } }; -#define Q_STATIC_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(size, offset) \ - { Q_BASIC_ATOMIC_INITIALIZER(-1), QArrayData::StaticDataFlags, size, 0, offset } \ - /**/ - -#define Q_STATIC_ARRAY_DATA_HEADER_INITIALIZER(type, size) \ - Q_STATIC_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(size,\ - ((sizeof(QArrayData) + (alignof(type) - 1)) & ~(alignof(type) - 1) )) \ - /**/ - //////////////////////////////////////////////////////////////////////////////// // Q_ARRAY_LITERAL @@ -411,16 +371,15 @@ struct QTypedArrayData Q_ARRAY_LITERAL_CHECK_LITERAL_TYPE(Type); \ \ /* Portable compile-time array size computation */ \ - Q_CONSTEXPR Type data[] = { __VA_ARGS__ }; Q_UNUSED(data); \ + static Type const data[] = { __VA_ARGS__ }; \ enum { Size = sizeof(data) / sizeof(data[0]) }; \ \ - static const QStaticArrayData<Type, Size> literal = { \ - Q_STATIC_ARRAY_DATA_HEADER_INITIALIZER(Type, Size), { __VA_ARGS__ } }; \ + static const QArrayData literal = { Q_BASIC_ATOMIC_INITIALIZER(-1), QArrayData::StaticDataFlags, 0 }; \ \ QArrayDataPointerRef<Type> ref = \ { static_cast<QTypedArrayData<Type> *>( \ - const_cast<QArrayData *>(&literal.header)), \ - const_cast<Type *>(literal.data), \ + const_cast<QArrayData *>(&literal)), \ + const_cast<Type *>(data), \ Size }; \ /**/ |