diff options
author | João Abecasis <joao.abecasis@nokia.com> | 2012-03-05 17:43:34 +0100 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-04-02 16:34:21 +0200 |
commit | 8c413f3eff2de761ae038294195831de753b9252 (patch) | |
tree | 124d46015c194aa91fd3df68f694761f6819cf02 /src/corelib/tools/qarraydatapointer.h | |
parent | 646dc6c5daeefa99c9af070802c39bc66dc4f1f0 (diff) |
Introduce QArrayData::detachCapacity
This follows QArrayData::detachFlags's lead. Given the (known) size for
a detached container, the function helps determine capacity, ensuring
the capacityReserved flag is respected.
This further helps aggregating behaviour on detach in QArrayData itself.
SimpleVector was previously using qMax(capacity(), newSize), but there's
no reason to pin the previous capacity value if reserve() wasn't
requested. It now uses detachCapacity().
Change-Id: Ide2d99ea7ecd2cd98ae4c1aa397b4475d09c8485
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/tools/qarraydatapointer.h')
-rw-r--r-- | src/corelib/tools/qarraydatapointer.h | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/corelib/tools/qarraydatapointer.h b/src/corelib/tools/qarraydatapointer.h index f5ad53aa54..4eb90ac35e 100644 --- a/src/corelib/tools/qarraydatapointer.h +++ b/src/corelib/tools/qarraydatapointer.h @@ -171,7 +171,7 @@ public: private: Data *clone(QArrayData::AllocationOptions options) const Q_REQUIRED_RESULT { - QArrayDataPointer copy(Data::allocate(d->alloc ? d->alloc : d->size, + QArrayDataPointer copy(Data::allocate(d->detachCapacity(d->size), options)); if (d->size) copy->copyAppend(d->begin(), d->end()); |