summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2020-05-22 11:26:21 +0200
committerLars Knoll <lars.knoll@qt.io>2020-07-06 21:30:47 +0200
commit0341bf2e979264b9f7606bd57e594a41c27a38cc (patch)
tree226be567b0eee672a38dd9b83494815d4bc0d110
parentc129362b4d9512bd33004d430bc3b817546cb1b7 (diff)
Make QArrayDataPointer::size a qsizetype
This is a next step towards making QList, QString and QByteArray able to deal with large sizes. Change-Id: Icad49b33f503401ac4912678b2f88584c6f91a63 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
-rw-r--r--src/corelib/text/qbytearray.cpp2
-rw-r--r--src/corelib/text/qbytearray.h2
-rw-r--r--src/corelib/text/qstring.cpp4
-rw-r--r--src/corelib/tools/qarraydataops.h4
-rw-r--r--src/corelib/tools/qarraydatapointer.h12
5 files changed, 12 insertions, 12 deletions
diff --git a/src/corelib/text/qbytearray.cpp b/src/corelib/text/qbytearray.cpp
index e0f720bc86..c138765e15 100644
--- a/src/corelib/text/qbytearray.cpp
+++ b/src/corelib/text/qbytearray.cpp
@@ -1675,7 +1675,7 @@ QByteArray &QByteArray::fill(char ch, int size)
void QByteArray::reallocData(uint alloc, Data::ArrayOptions options)
{
if (d->needsDetach()) {
- DataPointer dd(Data::allocate(alloc, options), qMin(int(alloc) - 1, d.size));
+ DataPointer dd(Data::allocate(alloc, options), qMin(qsizetype(alloc) - 1, d.size));
::memcpy(dd.data(), d.data(), dd.size);
dd.data()[dd.size] = 0;
d = dd;
diff --git a/src/corelib/text/qbytearray.h b/src/corelib/text/qbytearray.h
index c2ec72ae76..f4d4bf0745 100644
--- a/src/corelib/text/qbytearray.h
+++ b/src/corelib/text/qbytearray.h
@@ -417,7 +417,7 @@ public:
static inline QByteArray fromStdString(const std::string &s);
inline std::string toStdString() const;
- inline int size() const { return d->size; }
+ inline int size() const { return int(d->size); }
inline int count() const { return size(); }
inline int length() const { return size(); }
bool isNull() const;
diff --git a/src/corelib/text/qstring.cpp b/src/corelib/text/qstring.cpp
index 8e572691c6..c98b1f82b6 100644
--- a/src/corelib/text/qstring.cpp
+++ b/src/corelib/text/qstring.cpp
@@ -2364,7 +2364,7 @@ void QString::reallocData(uint alloc, bool grow)
allocOptions |= QArrayData::GrowsForward;
if (d->needsDetach()) {
- DataPointer dd(Data::allocate(alloc, allocOptions), qMin(int(alloc) - 1, d.size));
+ DataPointer dd(Data::allocate(alloc, allocOptions), qMin(qsizetype(alloc) - 1, d.size));
::memcpy(dd.data(), d.data(), dd.size * sizeof(QChar));
dd.data()[dd.size] = 0;
d = dd;
@@ -2595,7 +2595,7 @@ QString& QString::insert(int i, const QChar *unicode, int size)
if (Q_UNLIKELY(i > int(d.size)))
resize(i + size, QLatin1Char(' '));
else
- resize(d.size + size);
+ resize(int(d.size) + size);
::memmove(d.data() + i + size, d.data() + i, (d.size - i - size) * sizeof(QChar));
memcpy(d.data() + i, s, size * sizeof(QChar));
diff --git a/src/corelib/tools/qarraydataops.h b/src/corelib/tools/qarraydataops.h
index bea585e69a..a97f2da175 100644
--- a/src/corelib/tools/qarraydataops.h
+++ b/src/corelib/tools/qarraydataops.h
@@ -690,7 +690,7 @@ struct QMovableArrayOps
struct Mover
{
- Mover(T *&start, const T *finish, int &sz)
+ Mover(T *&start, const T *finish, qsizetype &sz)
: destination(start)
, source(start)
, n(finish - start)
@@ -707,7 +707,7 @@ struct QMovableArrayOps
T *&destination;
const T *const source;
size_t n;
- int &size;
+ qsizetype &size;
} mover(e, this->end(), this->size);
// destroy the elements we're erasing
diff --git a/src/corelib/tools/qarraydatapointer.h b/src/corelib/tools/qarraydatapointer.h
index aff603c32b..a7e8429469 100644
--- a/src/corelib/tools/qarraydatapointer.h
+++ b/src/corelib/tools/qarraydatapointer.h
@@ -70,17 +70,17 @@ public:
ref();
}
- constexpr QArrayDataPointer(Data *header, T *adata, size_t n = 0) noexcept
- : d(header), ptr(adata), size(int(n))
+ constexpr QArrayDataPointer(Data *header, T *adata, qsizetype n = 0) noexcept
+ : d(header), ptr(adata), size(n)
{
}
- explicit QArrayDataPointer(QPair<QTypedArrayData<T> *, T *> adata, size_t n = 0) noexcept
- : d(adata.first), ptr(adata.second), size(int(n))
+ explicit QArrayDataPointer(QPair<QTypedArrayData<T> *, T *> adata, qsizetype n = 0) noexcept
+ : d(adata.first), ptr(adata.second), size(n)
{
}
- static QArrayDataPointer fromRawData(const T *rawData, size_t length) noexcept
+ static QArrayDataPointer fromRawData(const T *rawData, qsizetype length) noexcept
{
Q_ASSERT(rawData || !length);
return { nullptr, const_cast<T *>(rawData), length };
@@ -212,7 +212,7 @@ protected:
T *ptr;
public:
- int size;
+ qsizetype size;
};
template <class T>