QArrayData/Pointer: s/QPair/std::pair/
Also port from qMakePair to just braced initialization and CTAD. Task-number: QTBUG-115841 Change-Id: Ifd7220ae88b101351e91d1488ce18715eb4880e5 Reviewed-by: Ahmad Samir <a.samirh78@gmail.com> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> (cherry picked from commit 95c7f88132646489bc17b8ea32facd76a19e19fa) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
4e8e6a1526
commit
f49980f0b7
@ -222,7 +222,7 @@ void *QArrayData::allocate2(QArrayData **dptr, qsizetype capacity, AllocationOpt
|
|||||||
return r.data;
|
return r.data;
|
||||||
}
|
}
|
||||||
|
|
||||||
QPair<QArrayData *, void *>
|
std::pair<QArrayData *, void *>
|
||||||
QArrayData::reallocateUnaligned(QArrayData *data, void *dataPointer,
|
QArrayData::reallocateUnaligned(QArrayData *data, void *dataPointer,
|
||||||
qsizetype objectSize, qsizetype capacity, AllocationOption option) noexcept
|
qsizetype objectSize, qsizetype capacity, AllocationOption option) noexcept
|
||||||
{
|
{
|
||||||
@ -233,7 +233,7 @@ QArrayData::reallocateUnaligned(QArrayData *data, void *dataPointer,
|
|||||||
qsizetype allocSize = r.size;
|
qsizetype allocSize = r.size;
|
||||||
capacity = r.elementCount;
|
capacity = r.elementCount;
|
||||||
if (Q_UNLIKELY(allocSize < 0))
|
if (Q_UNLIKELY(allocSize < 0))
|
||||||
return qMakePair<QArrayData *, void *>(nullptr, nullptr);
|
return {};
|
||||||
|
|
||||||
const qptrdiff offset = dataPointer
|
const qptrdiff offset = dataPointer
|
||||||
? reinterpret_cast<char *>(dataPointer) - reinterpret_cast<char *>(data)
|
? reinterpret_cast<char *>(dataPointer) - reinterpret_cast<char *>(data)
|
||||||
@ -248,7 +248,7 @@ QArrayData::reallocateUnaligned(QArrayData *data, void *dataPointer,
|
|||||||
} else {
|
} else {
|
||||||
dataPointer = nullptr;
|
dataPointer = nullptr;
|
||||||
}
|
}
|
||||||
return qMakePair(static_cast<QArrayData *>(header), dataPointer);
|
return {header, dataPointer};
|
||||||
}
|
}
|
||||||
|
|
||||||
void QArrayData::deallocate(QArrayData *data, qsizetype objectSize,
|
void QArrayData::deallocate(QArrayData *data, qsizetype objectSize,
|
||||||
|
@ -95,7 +95,7 @@ struct QArrayData
|
|||||||
static Q_CORE_EXPORT void *allocate2(QArrayData **pdata, qsizetype capacity,
|
static Q_CORE_EXPORT void *allocate2(QArrayData **pdata, qsizetype capacity,
|
||||||
AllocationOption option = QArrayData::KeepSize) noexcept;
|
AllocationOption option = QArrayData::KeepSize) noexcept;
|
||||||
|
|
||||||
[[nodiscard]] static Q_CORE_EXPORT QPair<QArrayData *, void *> reallocateUnaligned(QArrayData *data, void *dataPointer,
|
[[nodiscard]] static Q_CORE_EXPORT std::pair<QArrayData *, void *> reallocateUnaligned(QArrayData *data, void *dataPointer,
|
||||||
qsizetype objectSize, qsizetype newCapacity, AllocationOption option) noexcept;
|
qsizetype objectSize, qsizetype newCapacity, AllocationOption option) noexcept;
|
||||||
static Q_CORE_EXPORT void deallocate(QArrayData *data, qsizetype objectSize,
|
static Q_CORE_EXPORT void deallocate(QArrayData *data, qsizetype objectSize,
|
||||||
qsizetype alignment) noexcept;
|
qsizetype alignment) noexcept;
|
||||||
@ -125,7 +125,7 @@ struct QTypedArrayData
|
|||||||
{
|
{
|
||||||
struct AlignmentDummy { QtPrivate::AlignedQArrayData header; T data; };
|
struct AlignmentDummy { QtPrivate::AlignedQArrayData header; T data; };
|
||||||
|
|
||||||
[[nodiscard]] static QPair<QTypedArrayData *, T *> allocate(qsizetype capacity, AllocationOption option = QArrayData::KeepSize)
|
[[nodiscard]] static std::pair<QTypedArrayData *, T *> allocate(qsizetype capacity, AllocationOption option = QArrayData::KeepSize)
|
||||||
{
|
{
|
||||||
static_assert(sizeof(QTypedArrayData) == sizeof(QArrayData));
|
static_assert(sizeof(QTypedArrayData) == sizeof(QArrayData));
|
||||||
QArrayData *d;
|
QArrayData *d;
|
||||||
@ -143,16 +143,16 @@ struct QTypedArrayData
|
|||||||
// and yet we do offer results that have stricter alignment
|
// and yet we do offer results that have stricter alignment
|
||||||
result = __builtin_assume_aligned(result, Q_ALIGNOF(AlignmentDummy));
|
result = __builtin_assume_aligned(result, Q_ALIGNOF(AlignmentDummy));
|
||||||
#endif
|
#endif
|
||||||
return qMakePair(static_cast<QTypedArrayData *>(d), static_cast<T *>(result));
|
return {static_cast<QTypedArrayData *>(d), static_cast<T *>(result)};
|
||||||
}
|
}
|
||||||
|
|
||||||
static QPair<QTypedArrayData *, T *>
|
static std::pair<QTypedArrayData *, T *>
|
||||||
reallocateUnaligned(QTypedArrayData *data, T *dataPointer, qsizetype capacity, AllocationOption option)
|
reallocateUnaligned(QTypedArrayData *data, T *dataPointer, qsizetype capacity, AllocationOption option)
|
||||||
{
|
{
|
||||||
static_assert(sizeof(QTypedArrayData) == sizeof(QArrayData));
|
static_assert(sizeof(QTypedArrayData) == sizeof(QArrayData));
|
||||||
QPair<QArrayData *, void *> pair =
|
std::pair<QArrayData *, void *> pair =
|
||||||
QArrayData::reallocateUnaligned(data, dataPointer, sizeof(T), capacity, option);
|
QArrayData::reallocateUnaligned(data, dataPointer, sizeof(T), capacity, option);
|
||||||
return qMakePair(static_cast<QTypedArrayData *>(pair.first), static_cast<T *>(pair.second));
|
return {static_cast<QTypedArrayData *>(pair.first), static_cast<T *>(pair.second)};
|
||||||
}
|
}
|
||||||
|
|
||||||
static void deallocate(QArrayData *data) noexcept
|
static void deallocate(QArrayData *data) noexcept
|
||||||
|
@ -47,7 +47,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
Q_NODISCARD_CTOR
|
Q_NODISCARD_CTOR
|
||||||
explicit QArrayDataPointer(QPair<QTypedArrayData<T> *, T *> adata, qsizetype n = 0) noexcept
|
explicit QArrayDataPointer(std::pair<QTypedArrayData<T> *, T *> adata, qsizetype n = 0) noexcept
|
||||||
: d(adata.first), ptr(adata.second), size(n)
|
: d(adata.first), ptr(adata.second), size(n)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user