From fc87ff3d793a4b87d9d08f84a7cc3c632cf78a09 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 18 Mar 2011 17:14:16 +0100 Subject: Make the prolog function more generic --- tests/benchmarks/corelib/tools/qstring/main.cpp | 18 ++++++------------ 1 file 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 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("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) -- cgit v0.12