aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJoão Abecasis <joao.abecasis@nokia.com>2012-03-07 23:17:54 +0100
committerQt by Nokia <qt-info@nokia.com>2012-03-09 21:26:40 +0100
commit3c94c7eb7e622051677eb319f6a79e5edb8e2a12 (patch)
treeecead298d8152cf6676c217b20213f71bf5b66c6 /tests
parent8fd3c019169c45fbc6c8f29b69dc4c17fc8e4187 (diff)
Don't grow container when desired size is known
QList<Type>::reserve() is used upfront to allocate necessary memory in a one go. This tells us straight away whether allocation is possible at all and reduces re-allocations and consequent memory copies. This also has the side effect that no spare memory is allocated, also allowing up to (and including) INT_MAX elements to actually be stored in the underlying QList, as long as enough memory is available to satisfy the allocation request and subsequent fill. The qqmlecmascript::sequenceConversionIndexes was changed to not attempt INT_MAX allocations as, given enough memory and virtual address space, that might succeed but take a really long time. Change-Id: I4b0c965e9c23be78874343a70d7c155933c80903 Reviewed-by: Chris Adams <christopher.adams@nokia.com> Reviewed-by: Kent Hansen <kent.hansen@nokia.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qml/qqmlecmascript/data/sequenceConversion.indexes.qml14
-rw-r--r--tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp4
2 files changed, 0 insertions, 18 deletions
diff --git a/tests/auto/qml/qqmlecmascript/data/sequenceConversion.indexes.qml b/tests/auto/qml/qqmlecmascript/data/sequenceConversion.indexes.qml
index 23f1e90417..962e8dd474 100644
--- a/tests/auto/qml/qqmlecmascript/data/sequenceConversion.indexes.qml
+++ b/tests/auto/qml/qqmlecmascript/data/sequenceConversion.indexes.qml
@@ -71,19 +71,5 @@ Item {
success = false;
if (!verifyExpected(msco.intListProperty, 4))
success = false;
-
- // NOTE: while these two operations are technically
- // fine, we expect std::bad_alloc exceptions here
- // which we handle in the sequence wrapper.
- msco.intListProperty.length = maxIndex;
- if (msco.intListProperty.length != expectedLength)
- success = false;
- if (!verifyExpected(msco.intListProperty, 4))
- success = false;
- msco.intListProperty[maxIndex] = 15;
- if (msco.intListProperty.length != expectedLength)
- success = false;
- if (!verifyExpected(msco.intListProperty, 4))
- success = false;
}
}
diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
index 0dc0e5aca8..5770dc4e03 100644
--- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
+++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
@@ -4649,13 +4649,9 @@ void tst_qqmlecmascript::sequenceConversionIndexes()
QString w1 = qmlFile.toString() + QLatin1String(":34: Index out of range during length set");
QString w2 = qmlFile.toString() + QLatin1String(":41: Index out of range during indexed set");
QString w3 = qmlFile.toString() + QLatin1String(":48: Index out of range during indexed get");
- QString w4 = qmlFile.toString() + QLatin1String(":78: std::bad_alloc during length set");
- QString w5 = qmlFile.toString() + QLatin1String(":83: std::bad_alloc during indexed set");
QTest::ignoreMessage(QtWarningMsg, qPrintable(w1));
QTest::ignoreMessage(QtWarningMsg, qPrintable(w2));
QTest::ignoreMessage(QtWarningMsg, qPrintable(w3));
- QTest::ignoreMessage(QtWarningMsg, qPrintable(w4));
- QTest::ignoreMessage(QtWarningMsg, qPrintable(w5));
QMetaObject::invokeMethod(object, "indexedAccess");
QVERIFY(object->property("success").toBool());
delete object;