diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2012-06-04 21:36:46 +0200 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2019-12-07 14:18:04 +0100 |
commit | 64db4861bfcacc8849e8452b73d5c940d97aefd0 (patch) | |
tree | c39991072737ea1253adf5affb321ca7f4923f79 /tests/auto | |
parent | bf0b4f332a2f1ec9860c610d98cd27e483869bec (diff) |
Replace QArrayData::capacityReserved with a full flags field
Instead of stealing one bit from the alloc field, let's use a full
32-bit for the flags. The first flag to be in the field is the
CapacityReserved (even though the allocate() function will store some
others there, not relevant for now).
This is done in preparation for the need for more flags necessary
anyway.
Change-Id: I4c997d14743495e0d4558a6fb0a6042eb3d4975d
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'tests/auto')
-rw-r--r-- | tests/auto/corelib/tools/qarraydata/simplevector.h | 4 | ||||
-rw-r--r-- | tests/auto/corelib/tools/qarraydata/tst_qarraydata.cpp | 6 |
2 files changed, 4 insertions, 6 deletions
diff --git a/tests/auto/corelib/tools/qarraydata/simplevector.h b/tests/auto/corelib/tools/qarraydata/simplevector.h index ffc8ba770c..b5308e2231 100644 --- a/tests/auto/corelib/tools/qarraydata/simplevector.h +++ b/tests/auto/corelib/tools/qarraydata/simplevector.h @@ -139,10 +139,10 @@ public: return; if (n <= capacity()) { - if (d->capacityReserved) + if (d->flags & Data::CapacityReserved) return; if (!d->ref.isShared()) { - d->capacityReserved = 1; + d->flags |= Data::CapacityReserved; return; } } diff --git a/tests/auto/corelib/tools/qarraydata/tst_qarraydata.cpp b/tests/auto/corelib/tools/qarraydata/tst_qarraydata.cpp index d3e071bb1b..1a043f7797 100644 --- a/tests/auto/corelib/tools/qarraydata/tst_qarraydata.cpp +++ b/tests/auto/corelib/tools/qarraydata/tst_qarraydata.cpp @@ -155,11 +155,9 @@ void tst_QArrayData::sharedNullEmpty() QCOMPARE(null->size, 0); QCOMPARE(null->alloc, 0u); - QCOMPARE(null->capacityReserved, 0u); QCOMPARE(empty->size, 0); QCOMPARE(empty->alloc, 0u); - QCOMPARE(empty->capacityReserved, 0u); } void tst_QArrayData::staticData() @@ -602,7 +600,7 @@ void tst_QArrayData::allocate() QVERIFY(data->alloc > uint(capacity)); else QCOMPARE(data->alloc, uint(capacity)); - QCOMPARE(data->capacityReserved, uint(isCapacityReserved)); + QCOMPARE(bool(data->flags & QArrayData::CapacityReserved), isCapacityReserved); // Check that the allocated array can be used. Best tested with a // memory checker, such as valgrind, running. @@ -647,7 +645,7 @@ void tst_QArrayData::reallocate() QVERIFY(data->alloc > uint(newCapacity)); else QCOMPARE(data->alloc, uint(newCapacity)); - QCOMPARE(data->capacityReserved, uint(isCapacityReserved)); + QCOMPARE(!(data->flags & QArrayData::CapacityReserved), !isCapacityReserved); for (int i = 0; i < capacity; ++i) QCOMPARE(static_cast<char *>(data->data())[i], 'A'); |