From d91b4f0b13926a0861d7e172f14437d20d06332e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Thu, 5 Jan 2012 16:29:42 +0100 Subject: Remove shared_empty and unsharable_empty from API They still exist and help avoid allocation of "empty" array headers, but they're no longer part of the public API, thus reducing relocatable symbols and relocations in inline code. This means an extra non-inline call on QArrayDataPointer::clear and setSharable operations, which are (expensive) detaching operations, anyway. Change-Id: Iea804e5ddc8af55ebc0951ca17a7a4e8401abc55 Reviewed-by: Bradley T. Hughes Reviewed-by: Thiago Macieira --- tests/auto/corelib/tools/qarraydata/tst_qarraydata.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'tests/auto/corelib/tools/qarraydata') diff --git a/tests/auto/corelib/tools/qarraydata/tst_qarraydata.cpp b/tests/auto/corelib/tools/qarraydata/tst_qarraydata.cpp index e8edab20e4..47d5e2a32b 100644 --- a/tests/auto/corelib/tools/qarraydata/tst_qarraydata.cpp +++ b/tests/auto/corelib/tools/qarraydata/tst_qarraydata.cpp @@ -153,7 +153,7 @@ void tst_QArrayData::referenceCounting() void tst_QArrayData::sharedNullEmpty() { QArrayData *null = const_cast(&QArrayData::shared_null); - QArrayData *empty = const_cast(&QArrayData::shared_empty); + QArrayData *empty = QArrayData::allocate(1, Q_ALIGNOF(QArrayData), 0, false, true); QVERIFY(null->ref.isStatic()); QVERIFY(null->ref.isSharable()); @@ -492,16 +492,22 @@ void tst_QArrayData::allocate_data() { "void *", sizeof(void *), Q_ALIGNOF(void *) } }; + QArrayData *shared_empty = QArrayData::allocate(0, Q_ALIGNOF(QArrayData), 0, false, true); + QArrayData *unsharable_empty = QArrayData::allocate(0, Q_ALIGNOF(QArrayData), 0, false, false); + + QVERIFY(shared_empty); + QVERIFY(unsharable_empty); + struct { char const *description; bool isCapacityReserved; bool isSharable; const QArrayData *commonEmpty; } options[] = { - { "Default", false, true, &QArrayData::shared_empty }, - { "Reserved", true, true, &QArrayData::shared_empty }, - { "Reserved | Unsharable", true, false, &QArrayData::unsharable_empty }, - { "Unsharable", false, false, &QArrayData::unsharable_empty }, + { "Default", false, true, shared_empty }, + { "Reserved", true, true, shared_empty }, + { "Reserved | Unsharable", true, false, unsharable_empty }, + { "Unsharable", false, false, unsharable_empty }, }; for (size_t i = 0; i < sizeof(types)/sizeof(types[0]); ++i) @@ -635,7 +641,7 @@ void tst_QArrayData::typedData() { QTypedArrayData *null = QTypedArrayData::sharedNull(); - QTypedArrayData *empty = QTypedArrayData::sharedEmpty(); + QTypedArrayData *empty = QTypedArrayData::allocate(0); QVERIFY(null != empty); -- cgit v1.2.3