summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools/qarraydata.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/tools/qarraydata.h')
-rw-r--r--src/corelib/tools/qarraydata.h15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/corelib/tools/qarraydata.h b/src/corelib/tools/qarraydata.h
index 0063cf046fe..94182a531c3 100644
--- a/src/corelib/tools/qarraydata.h
+++ b/src/corelib/tools/qarraydata.h
@@ -218,16 +218,23 @@ struct QTypedArrayData
AllocationOptions options = Default)
{
Q_STATIC_ASSERT(sizeof(QTypedArrayData) == sizeof(QArrayData));
- return static_cast<QTypedArrayData *>(QArrayData::allocate(sizeof(T),
- alignof(AlignmentDummy), capacity, options));
+ void *result = QArrayData::allocate(sizeof(T),
+ alignof(AlignmentDummy), capacity, options);
+#if (defined(Q_CC_GNU) && Q_CC_GNU >= 407) || QT_HAS_BUILTIN(__builtin_assume_aligned)
+ result = __builtin_assume_aligned(result, Q_ALIGNOF(AlignmentDummy));
+#endif
+ return static_cast<QTypedArrayData *>(result);
}
static QTypedArrayData *reallocateUnaligned(QTypedArrayData *data, size_t capacity,
AllocationOptions options = Default)
{
Q_STATIC_ASSERT(sizeof(QTypedArrayData) == sizeof(QArrayData));
- return static_cast<QTypedArrayData *>(QArrayData::reallocateUnaligned(data, sizeof(T),
- capacity, options));
+ void *result = QArrayData::reallocateUnaligned(data, sizeof(T), capacity, options));
+#if (defined(Q_CC_GNU) && Q_CC_GNU >= 407) || QT_HAS_BUILTIN(__builtin_assume_aligned)
+ result =__builtin_assume_aligned(result, Q_ALIGNOF(AlignmentDummy));
+#endif
+ return static_cast<QTypedArrayData *>(result);
}
static void deallocate(QArrayData *data)