summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2019-11-16 16:22:36 +0100
committerLars Knoll <lars.knoll@qt.io>2020-07-02 11:42:11 +0200
commit1480aa895bc58eb43edffbc4b2aa027147d3280d (patch)
tree846ab512eaee77940bc70b2b6da8fba10fad0ebf /src/corelib
parentca8b2a36324d205d4a8482b522f32f5377b0b962 (diff)
Move the reallocate() method from QArrayDataPointer to the Ops class
And only implement it for QPodArrayOps, as that's the only case where we should be using it. Change-Id: If48f3e4b142c322d3451309d6d1cf68aee569ea2 Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/text/qbytearray.cpp2
-rw-r--r--src/corelib/text/qstring.cpp2
-rw-r--r--src/corelib/tools/qarraydataops.h10
-rw-r--r--src/corelib/tools/qarraydatapointer.h6
4 files changed, 12 insertions, 8 deletions
diff --git a/src/corelib/text/qbytearray.cpp b/src/corelib/text/qbytearray.cpp
index 77f4110601..95a1f9f52c 100644
--- a/src/corelib/text/qbytearray.cpp
+++ b/src/corelib/text/qbytearray.cpp
@@ -1673,7 +1673,7 @@ void QByteArray::reallocData(uint alloc, Data::ArrayOptions options)
dd.data()[dd.size] = 0;
d = dd;
} else {
- d.reallocate(alloc, options);
+ d->reallocate(alloc, options);
}
}
diff --git a/src/corelib/text/qstring.cpp b/src/corelib/text/qstring.cpp
index 5bd063ee42..d327264218 100644
--- a/src/corelib/text/qstring.cpp
+++ b/src/corelib/text/qstring.cpp
@@ -2367,7 +2367,7 @@ void QString::reallocData(uint alloc, bool grow)
dd.data()[dd.size] = 0;
d = dd;
} else {
- d.reallocate(alloc, allocOptions);
+ d->reallocate(alloc, allocOptions);
}
}
diff --git a/src/corelib/tools/qarraydataops.h b/src/corelib/tools/qarraydataops.h
index 1d74f49993..33ad13c6b7 100644
--- a/src/corelib/tools/qarraydataops.h
+++ b/src/corelib/tools/qarraydataops.h
@@ -62,6 +62,9 @@ template <class T>
struct QPodArrayOps
: public QArrayDataPointer<T>
{
+private:
+ typedef QTypedArrayData<T> Data;
+public:
typedef typename QArrayDataPointer<T>::parameter_type parameter_type;
void appendInitialize(size_t newSize)
@@ -228,6 +231,13 @@ struct QPodArrayOps
}
return true;
}
+
+ void reallocate(qsizetype alloc, typename Data::ArrayOptions options)
+ {
+ auto pair = Data::reallocateUnaligned(this->d, this->ptr, alloc, options);
+ this->d = pair.first;
+ this->ptr = pair.second;
+ }
};
QT_WARNING_POP
diff --git a/src/corelib/tools/qarraydatapointer.h b/src/corelib/tools/qarraydatapointer.h
index a17cf4a101..9bdbea2bde 100644
--- a/src/corelib/tools/qarraydatapointer.h
+++ b/src/corelib/tools/qarraydatapointer.h
@@ -199,12 +199,6 @@ public:
typename Data::ArrayOptions detachFlags() const noexcept { return d->detachFlags(); }
typename Data::ArrayOptions cloneFlags() const noexcept { return d->cloneFlags(); }
- void reallocate(uint alloc, typename Data::ArrayOptions options)
- {
- auto pair = Data::reallocateUnaligned(d, ptr, alloc, options);
- d = pair.first;
- ptr = pair.second;
- }
Data *d_ptr() { return d; }
private: