summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools/qvector.h
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2012-06-11 19:42:05 +0200
committerLars Knoll <lars.knoll@qt.io>2019-12-08 10:29:09 +0100
commit62c673ccc6f81cee09a25f5acceec2768cea4672 (patch)
tree883720fc4a6d333dbf3afb7b8276bbd33d202ffc /src/corelib/tools/qvector.h
parenta3aa2fcfa72ab69bdbded26dcd43e37b35796a17 (diff)
Add reference-count manipulation functions to QArrayData and hide ref
The next change will stop using some values in the reference counter as settings from the data. Change-Id: I94df1fe643896373fac2f000fff55bc7708fc807 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/corelib/tools/qvector.h')
-rw-r--r--src/corelib/tools/qvector.h20
1 files changed, 10 insertions, 10 deletions
diff --git a/src/corelib/tools/qvector.h b/src/corelib/tools/qvector.h
index a596beedcf..d9512ee90e 100644
--- a/src/corelib/tools/qvector.h
+++ b/src/corelib/tools/qvector.h
@@ -89,7 +89,7 @@ public:
explicit QVector(int size);
QVector(int size, const T &t);
inline QVector(const QVector<T> &v);
- inline ~QVector() { if (!d->ref.deref()) freeData(d); }
+ inline ~QVector() { if (!d->deref()) freeData(d); }
QVector<T> &operator=(const QVector<T> &v);
QVector(QVector<T> &&other) noexcept : d(other.d) { other.d = Data::sharedNull(); }
QVector<T> &operator=(QVector<T> &&other) noexcept
@@ -114,17 +114,17 @@ public:
void reserve(int size);
inline void squeeze()
{
- if (d->size < int(d->alloc)) {
+ if (d->size < int(d->allocatedCapacity())) {
if (!d->size) {
*this = QVector<T>();
return;
}
- realloc(d->size, QArrayData::ArrayOptions(d->flags));
+ realloc(d->size, d->detachFlags());
}
}
inline void detach();
- inline bool isDetached() const { return !d->ref.isShared(); }
+ inline bool isDetached() const { return !d->isShared(); }
inline bool isSharedWith(const QVector<T> &other) const { return d == other.d; }
@@ -365,7 +365,7 @@ void QVector<T>::destruct(T *from, T *to)
template <typename T>
inline QVector<T>::QVector(const QVector<T> &v)
{
- if (v.d->ref.ref()) {
+ if (v.d->ref()) {
d = v.d;
} else {
if (v.d->flags & Data::CapacityReserved) {
@@ -391,7 +391,7 @@ template <typename T>
void QVector<T>::detach()
{
// ### check whether this is still required
- if (d->ref.isStatic())
+ if (d->isStatic())
return;
if (d->needsDetach())
@@ -581,14 +581,14 @@ void QVector<T>::realloc(int aalloc, QArrayData::ArrayOptions options)
Q_ASSERT(aalloc >= d->size);
Data *x = d;
- const bool isShared = d->ref.isShared();
+ const bool isShared = d->isShared();
QT_TRY {
// allocate memory
x = Data::allocate(aalloc, options);
Q_CHECK_PTR(x);
// aalloc is bigger then 0 so it is not [un]sharedEmpty
- Q_ASSERT(!x->ref.isStatic());
+ Q_ASSERT(!x->isStatic());
x->size = d->size;
T *srcBegin = d->begin();
@@ -621,7 +621,7 @@ void QVector<T>::realloc(int aalloc, QArrayData::ArrayOptions options)
}
Q_ASSERT(d != x);
- if (!d->ref.deref()) {
+ if (!d->deref()) {
if (!QTypeInfoQuery<T>::isRelocatable || !aalloc || (isShared && QTypeInfo<T>::isComplex)) {
// data was copy constructed, we need to call destructors
// or if !alloc we did nothing to the old 'd'.
@@ -701,7 +701,7 @@ void QVector<T>::removeLast()
Q_ASSERT(!isEmpty());
Q_ASSERT(d->allocatedCapacity());
- if (d->ref.isShared())
+ if (d->isShared())
detach();
--d->size;
if (QTypeInfo<T>::isComplex)