summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/tools/qvector
diff options
context:
space:
mode:
authorThorbjørn Martsum <tmartsum@gmail.com>2013-01-10 19:42:59 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-03-07 08:37:26 +0100
commit3222db0937aaf1ae5681bc124406ec37f550bc7c (patch)
tree3c26a72d5a7838706266e2c02a05d35c85622d83 /tests/auto/corelib/tools/qvector
parentab52e722926d495e29263e59a466ad5ff0106275 (diff)
QVector - removeLast optimize
In case somebody uses QVector as a stack, it is not fair to have takeLast, removeLast and pop_back to do way too much work. This is still very slow compared to std::vector::pop_back (mostly due implicit sharing), however it is more than a factor faster than before. Change-Id: I636872675e80c8ca0c8ebc94b04f587a2dcd6d8d Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'tests/auto/corelib/tools/qvector')
-rw-r--r--tests/auto/corelib/tools/qvector/tst_qvector.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/tests/auto/corelib/tools/qvector/tst_qvector.cpp b/tests/auto/corelib/tools/qvector/tst_qvector.cpp
index 99fbb9cf98..53caec4a64 100644
--- a/tests/auto/corelib/tools/qvector/tst_qvector.cpp
+++ b/tests/auto/corelib/tools/qvector/tst_qvector.cpp
@@ -1479,6 +1479,15 @@ void tst_QVector::removeFirstLast() const
QCOMPARE(v2.at(0), 1);
QCOMPARE(v3.at(0), 1);
QCOMPARE(v3.at(1), 2);
+
+ // Remove last with shared
+ QVector<int> z1, z2;
+ z1.append(9);
+ z2 = z1;
+ z1.removeLast();
+ QCOMPARE(z1.size(), 0);
+ QCOMPARE(z2.size(), 1);
+ QCOMPARE(z2.at(0), 9);
}