diff options
author | Thiago Macieira <thiago.macieira@nokia.com> | 2011-03-18 16:14:16 (GMT) |
---|---|---|
committer | Thiago Macieira <thiago.macieira@nokia.com> | 2011-03-22 14:51:47 (GMT) |
commit | fc87ff3d793a4b87d9d08f84a7cc3c632cf78a09 (patch) | |
tree | eb27e20cb5fe9b08d968023e957414101f8bd82d | |
parent | 8f85657308ae7ba4196713ef57f0c918d5d4f64a (diff) | |
download | Qt-fc87ff3d793a4b87d9d08f84a7cc3c632cf78a09.zip Qt-fc87ff3d793a4b87d9d08f84a7cc3c632cf78a09.tar.gz Qt-fc87ff3d793a4b87d9d08f84a7cc3c632cf78a09.tar.bz2 |
Make the prolog function more generic
-rw-r--r-- | tests/benchmarks/corelib/tools/qstring/main.cpp | 18 |
1 files changed, 6 insertions, 12 deletions
diff --git a/tests/benchmarks/corelib/tools/qstring/main.cpp b/tests/benchmarks/corelib/tools/qstring/main.cpp index 6f5082e..dfe3015 100644 --- a/tests/benchmarks/corelib/tools/qstring/main.cpp +++ b/tests/benchmarks/corelib/tools/qstring/main.cpp @@ -1442,6 +1442,9 @@ void tst_QString::fromLatin1() const } } +typedef void (* FromLatin1Function)(ushort *, const char *, int); +Q_DECLARE_METATYPE(FromLatin1Function) + void fromLatin1_regular(ushort *dst, const char *str, int size) { // from qstring.cpp: @@ -1474,13 +1477,7 @@ void fromLatin1_sse2_qt47(ushort *dst, const char *str, int size) *dst++ = (uchar)*str++; } -static inline void fromLatin1_prolog(ushort *dst, const char *str, uint size) -{ - while (size--) { - *dst++ = (uchar)*str++; - } -} - +template<FromLatin1Function prologFunction> void fromLatin1_sse2_withprolog(ushort *dst, const char *str, int size) { // same as the Qt 4.7 code, but we attempt to align at the prolog @@ -1490,7 +1487,7 @@ void fromLatin1_sse2_withprolog(ushort *dst, const char *str, int size) uint misalignment = uint(quintptr(dst) & 0xf); uint prologCount = (16 - misalignment) / 2; - fromLatin1_prolog(dst, str, prologCount); + prologFunction(dst, str, prologCount); size -= prologCount; dst += prologCount; @@ -1521,15 +1518,12 @@ void fromLatin1_sse2_withprolog(ushort *dst, const char *str, int size) } -typedef void (* FromLatin1Function)(ushort *, const char *, int); -Q_DECLARE_METATYPE(FromLatin1Function) - void tst_QString::fromLatin1Alternatives_data() const { QTest::addColumn<FromLatin1Function>("function"); QTest::newRow("regular") << &fromLatin1_regular; QTest::newRow("sse2-qt4.7") << &fromLatin1_sse2_qt47; - QTest::newRow("sse2-with-prolog") << &fromLatin1_sse2_withprolog; + QTest::newRow("sse2-with-prolog") << &fromLatin1_sse2_withprolog<&fromLatin1_regular>; } static void fromLatin1Alternatives_internal(FromLatin1Function function, bool doVerify) |