summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/tools')
-rw-r--r--src/corelib/tools/qarraydataops.h2
-rw-r--r--src/corelib/tools/qarraydatapointer.h11
-rw-r--r--src/corelib/tools/qlist.h18
3 files changed, 19 insertions, 12 deletions
diff --git a/src/corelib/tools/qarraydataops.h b/src/corelib/tools/qarraydataops.h
index bd8ead0a805..6ef378a085b 100644
--- a/src/corelib/tools/qarraydataops.h
+++ b/src/corelib/tools/qarraydataops.h
@@ -236,7 +236,7 @@ public:
if (it == end)
return result;
- QPodArrayOps<T> other{ Data::allocate(this->size), this->size };
+ QPodArrayOps<T> other(this->size, this->size);
Q_CHECK_PTR(other.data());
auto dest = other.begin();
// std::uninitialized_copy will fallback to ::memcpy/memmove()
diff --git a/src/corelib/tools/qarraydatapointer.h b/src/corelib/tools/qarraydatapointer.h
index a77db21c99b..201f3e665dd 100644
--- a/src/corelib/tools/qarraydatapointer.h
+++ b/src/corelib/tools/qarraydatapointer.h
@@ -52,6 +52,13 @@ public:
{
}
+ Q_NODISCARD_CTOR explicit
+ QArrayDataPointer(qsizetype alloc, qsizetype n = 0,
+ QArrayData::AllocationOption option = QArrayData::KeepSize)
+ : QArrayDataPointer(Data::allocate(alloc, option), n)
+ {
+ }
+
Q_NODISCARD_CTOR
static QArrayDataPointer fromRawData(const T *rawData, qsizetype length) noexcept
{
@@ -326,11 +333,11 @@ public:
if constexpr (IsFwdIt) {
const qsizetype n = std::distance(first, last);
if (needsDetach() || n > constAllocatedCapacity()) {
- QArrayDataPointer allocated(Data::allocate(detachCapacity(n)));
+ QArrayDataPointer allocated(detachCapacity(n));
swap(allocated);
}
} else if (needsDetach()) {
- QArrayDataPointer allocated(Data::allocate(allocatedCapacity()));
+ QArrayDataPointer allocated(allocatedCapacity());
swap(allocated);
// We don't want to copy data that we know we'll overwrite
}
diff --git a/src/corelib/tools/qlist.h b/src/corelib/tools/qlist.h
index eafdfce140b..fc526c43cf0 100644
--- a/src/corelib/tools/qlist.h
+++ b/src/corelib/tools/qlist.h
@@ -276,20 +276,20 @@ public:
public:
QList() = default;
explicit QList(qsizetype size)
- : d(Data::allocate(size))
+ : d(size)
{
if (size)
d->appendInitialize(size);
}
QList(qsizetype size, parameter_type t)
- : d(Data::allocate(size))
+ : d(size)
{
if (size)
d->copyAppend(size, t);
}
inline QList(std::initializer_list<T> args)
- : d(Data::allocate(qsizetype(args.size())))
+ : d(qsizetype(args.size()))
{
if (args.size())
d->copyAppend(args.begin(), args.end());
@@ -308,7 +308,7 @@ public:
} else {
const auto distance = std::distance(i1, i2);
if (distance) {
- d = DataPointer(Data::allocate(qsizetype(distance)));
+ d = DataPointer(qsizetype(distance));
// appendIteratorRange can deal with contiguous iterators on its own,
// this is an optimization for C++17 code.
if constexpr (std::is_same_v<std::decay_t<InputIterator>, iterator> ||
@@ -424,7 +424,7 @@ public:
return;
if (d->needsDetach()) {
// must allocate memory
- DataPointer detached(Data::allocate(d.allocatedCapacity()));
+ DataPointer detached(d.allocatedCapacity());
d.swap(detached);
} else {
d->truncate(0);
@@ -747,7 +747,7 @@ void QList<T>::reserve(qsizetype asize)
}
}
- DataPointer detached(Data::allocate(qMax(asize, size())));
+ DataPointer detached(qMax(asize, size()));
detached->copyAppend(d->begin(), d->end());
if (detached.d_ptr())
detached->setFlag(Data::CapacityReserved);
@@ -761,7 +761,7 @@ inline void QList<T>::squeeze()
return;
if (d->needsDetach() || size() < capacity()) {
// must allocate memory
- DataPointer detached(Data::allocate(size()));
+ DataPointer detached(size());
if (size()) {
if (d.needsDetach())
detached->copyAppend(d.data(), d.data() + d.size);
@@ -890,7 +890,7 @@ inline QList<T> &QList<T>::fill(parameter_type t, qsizetype newSize)
newSize = size();
if (d->needsDetach() || newSize > capacity()) {
// must allocate memory
- DataPointer detached(Data::allocate(d->detachCapacity(newSize)));
+ DataPointer detached(d->detachCapacity(newSize));
detached->copyAppend(newSize, t);
d.swap(detached);
} else {
@@ -972,7 +972,7 @@ inline QList<T> QList<T>::mid(qsizetype pos, qsizetype len) const
}
// Allocate memory
- DataPointer copied(Data::allocate(l));
+ DataPointer copied(l);
copied->copyAppend(data() + p, data() + p + l);
return copied;
}