summaryrefslogtreecommitdiffstats
path: root/tests/auto/qlist
diff options
context:
space:
mode:
authorOswald Buddenhagen <oswald.buddenhagen@nokia.com>2010-01-28 20:07:18 (GMT)
committerOswald Buddenhagen <oswald.buddenhagen@nokia.com>2010-02-16 18:10:38 (GMT)
commitc03b21d272f617b037ad9d0ccaa2f442638bf302 (patch)
tree81ee508df0a38dc2decd6017f39e777af0416574 /tests/auto/qlist
parent5723f1bcb538a5624cbed871c34507ff26285878 (diff)
downloadQt-c03b21d272f617b037ad9d0ccaa2f442638bf302.zip
Qt-c03b21d272f617b037ad9d0ccaa2f442638bf302.tar.gz
Qt-c03b21d272f617b037ad9d0ccaa2f442638bf302.tar.bz2
optimize QList::mid()
instead of append()ing each element separately, reserve enough space and do a low-level node copy. obviously, the gain for small simple types is the biggest. Reviewed-by: joao Reviewed-by: denis
Diffstat (limited to 'tests/auto/qlist')
-rw-r--r--tests/auto/qlist/tst_qlist.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/tests/auto/qlist/tst_qlist.cpp b/tests/auto/qlist/tst_qlist.cpp
index 59b2c7b..a590fca 100644
--- a/tests/auto/qlist/tst_qlist.cpp
+++ b/tests/auto/qlist/tst_qlist.cpp
@@ -60,6 +60,7 @@ private slots:
void length() const;
void lengthSignature() const;
void append() const;
+ void mid() const;
};
void tst_QList::length() const
@@ -129,5 +130,14 @@ void tst_QList::append() const
}
+void tst_QList::mid() const
+{
+ QList<QString> list;
+ list << "foo" << "bar" << "baz" << "bak" << "buck" << "hello" << "kitty";
+
+ QCOMPARE(list.mid(3, 3),
+ QList<QString>() << "bak" << "buck" << "hello");
+}
+
QTEST_APPLESS_MAIN(tst_QList)
#include "tst_qlist.moc"