diff options
author | Thiago Macieira <thiago.macieira@nokia.com> | 2011-03-18 16:29:55 (GMT) |
---|---|---|
committer | Thiago Macieira <thiago.macieira@nokia.com> | 2011-03-22 14:51:50 (GMT) |
commit | c4cd963007b957c247cecb35137b0c814202af0f (patch) | |
tree | 58748e03f38c36f0fb4a7db4a9c96144e7ca7085 /tests | |
parent | d21a4d60394a4372c6a440d3a7b6606e0b209e70 (diff) | |
download | Qt-c4cd963007b957c247cecb35137b0c814202af0f.zip Qt-c4cd963007b957c247cecb35137b0c814202af0f.tar.gz Qt-c4cd963007b957c247cecb35137b0c814202af0f.tar.bz2 |
Optimise the prolog even further
Diffstat (limited to 'tests')
-rw-r--r-- | tests/benchmarks/corelib/tools/qstring/main.cpp | 49 |
1 files changed, 33 insertions, 16 deletions
diff --git a/tests/benchmarks/corelib/tools/qstring/main.cpp b/tests/benchmarks/corelib/tools/qstring/main.cpp index 0aff77c..4d2c8fa 100644 --- a/tests/benchmarks/corelib/tools/qstring/main.cpp +++ b/tests/benchmarks/corelib/tools/qstring/main.cpp @@ -1479,22 +1479,39 @@ void fromLatin1_sse2_qt47(ushort *dst, const char *str, int size) void fromLatin1_prolog_unrolled(ushort *dst, const char *str, int size) { - switch (size) { - case 7: - dst[6] = (uchar)str[6]; - case 6: - dst[5] = (uchar)str[5]; - case 5: - dst[4] = (uchar)str[4]; - case 4: - dst[3] = (uchar)str[3]; - case 3: - dst[2] = (uchar)str[2]; - case 2: - dst[1] = (uchar)str[1]; - case 1: - dst[0] = (uchar)str[0]; - } + // QString's data pointer is most often ending in 0x2 or 0xa + // that means the two most common values for size are (8-1)=7 and (8-5)=3 + if (size == 7) + goto copy_7; + if (size == 3) + goto copy_3; + + if (size == 6) + goto copy_6; + if (size == 5) + goto copy_5; + if (size == 4) + goto copy_4; + if (size == 2) + goto copy_2; + if (size == 1) + goto copy_1; + return; + +copy_7: + dst[6] = (uchar)str[6]; +copy_6: + dst[5] = (uchar)str[5]; +copy_5: + dst[4] = (uchar)str[4]; +copy_4: + dst[3] = (uchar)str[3]; +copy_3: + dst[2] = (uchar)str[2]; +copy_2: + dst[1] = (uchar)str[1]; +copy_1: + dst[0] = (uchar)str[0]; } template<FromLatin1Function prologFunction> |