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>
This commit is contained in:
parent
ca8b2a3632
commit
1480aa895b
@ -1673,7 +1673,7 @@ void QByteArray::reallocData(uint alloc, Data::ArrayOptions options)
|
|||||||
dd.data()[dd.size] = 0;
|
dd.data()[dd.size] = 0;
|
||||||
d = dd;
|
d = dd;
|
||||||
} else {
|
} else {
|
||||||
d.reallocate(alloc, options);
|
d->reallocate(alloc, options);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2367,7 +2367,7 @@ void QString::reallocData(uint alloc, bool grow)
|
|||||||
dd.data()[dd.size] = 0;
|
dd.data()[dd.size] = 0;
|
||||||
d = dd;
|
d = dd;
|
||||||
} else {
|
} else {
|
||||||
d.reallocate(alloc, allocOptions);
|
d->reallocate(alloc, allocOptions);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,6 +62,9 @@ template <class T>
|
|||||||
struct QPodArrayOps
|
struct QPodArrayOps
|
||||||
: public QArrayDataPointer<T>
|
: public QArrayDataPointer<T>
|
||||||
{
|
{
|
||||||
|
private:
|
||||||
|
typedef QTypedArrayData<T> Data;
|
||||||
|
public:
|
||||||
typedef typename QArrayDataPointer<T>::parameter_type parameter_type;
|
typedef typename QArrayDataPointer<T>::parameter_type parameter_type;
|
||||||
|
|
||||||
void appendInitialize(size_t newSize)
|
void appendInitialize(size_t newSize)
|
||||||
@ -228,6 +231,13 @@ struct QPodArrayOps
|
|||||||
}
|
}
|
||||||
return true;
|
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
|
QT_WARNING_POP
|
||||||
|
|
||||||
|
@ -199,12 +199,6 @@ public:
|
|||||||
typename Data::ArrayOptions detachFlags() const noexcept { return d->detachFlags(); }
|
typename Data::ArrayOptions detachFlags() const noexcept { return d->detachFlags(); }
|
||||||
typename Data::ArrayOptions cloneFlags() const noexcept { return d->cloneFlags(); }
|
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; }
|
Data *d_ptr() { return d; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user