diff options
author | Olivier Goffart <olivier.goffart@nokia.com> | 2010-10-28 09:59:32 (GMT) |
---|---|---|
committer | Olivier Goffart <olivier.goffart@nokia.com> | 2010-10-29 09:48:04 (GMT) |
commit | 4bfd68ccbda50fa3336d6ee6875d87b1b308b870 (patch) | |
tree | 0e57a67d80643dcc2caca3d3e3f3fe11bf065a8d /tests/auto | |
parent | 77819edac505823226c40033e76d2dda0e8b363a (diff) | |
download | Qt-4bfd68ccbda50fa3336d6ee6875d87b1b308b870.zip Qt-4bfd68ccbda50fa3336d6ee6875d87b1b308b870.tar.gz Qt-4bfd68ccbda50fa3336d6ee6875d87b1b308b870.tar.bz2 |
qSwap: use std::swap as implementation, and specialize std::swap for our container
std::swap might be reimplemented for many types. That might speedup
our Qt algorithms that uses qSwap. (std::swap also use std::move)
Specialize std::swap for our shared type, so stl algorithls work faster
Reviewed-by: Joao
Diffstat (limited to 'tests/auto')
-rw-r--r-- | tests/auto/qalgorithms/tst_qalgorithms.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/auto/qalgorithms/tst_qalgorithms.cpp b/tests/auto/qalgorithms/tst_qalgorithms.cpp index 690bbbd..17e6c04 100644 --- a/tests/auto/qalgorithms/tst_qalgorithms.cpp +++ b/tests/auto/qalgorithms/tst_qalgorithms.cpp @@ -81,6 +81,7 @@ private slots: void test_qBinaryFind(); void qBinaryFindOneEntry(); void swap(); + void swap2(); void sortEmptyList(); void sortedList(); void sortAPItest(); @@ -521,6 +522,28 @@ void tst_QAlgorithms::swap() } } +namespace SwapTest { + struct ST { int i; int j; }; + void swap(ST &a, ST &b) { + a.i = b.j; + b.i = a.j; + } +} + +void tst_QAlgorithms::swap2() +{ + { +#ifndef QT_NO_SQL + //check the namespace lookup works correctly + SwapTest::ST a = { 45, 65 }; + SwapTest::ST b = { 48, 68 }; + qSwap(a, b); + QCOMPARE(a.i, 68); + QCOMPARE(b.i, 65); +#endif + } +} + void tst_QAlgorithms::sortEmptyList() { // Only test if it crashes |