From d7287f595a5a8fe5d44d0b8c821362a4bb290c96 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 16 Jan 2014 17:59:45 -0800 Subject: Make QTextDecoder use our qt_from_latin1 code Disassembly shows the Intel compiler does expand to SIMD, but a much worse code than ours. Clang 3.4 does generate a compact SIMD version, probably of the same quality as our hand-written code. And GCC 4.7 through 4.9 don't generate SIMD at all. So let's use the most efficient version. Change-Id: I418e201a774ac0df1fb2b7a7d9589df7c9b655db Reviewed-by: Lars Knoll --- src/corelib/codecs/qtextcodec.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/corelib/codecs') diff --git a/src/corelib/codecs/qtextcodec.cpp b/src/corelib/codecs/qtextcodec.cpp index 2552ddebe9..7e3e629c47 100644 --- a/src/corelib/codecs/qtextcodec.cpp +++ b/src/corelib/codecs/qtextcodec.cpp @@ -993,6 +993,8 @@ QString QTextDecoder::toUnicode(const char *chars, int len) return c->toUnicode(chars, len, &state); } +// in qstring.cpp: +void qt_from_latin1(ushort *dst, const char *str, size_t size); /*! \overload @@ -1005,12 +1007,10 @@ void QTextDecoder::toUnicode(QString *target, const char *chars, int len) case 106: // utf8 static_cast(c)->convertToUnicode(target, chars, len, &state); break; - case 4: { // latin1 + case 4: // latin1 target->resize(len); - ushort *data = (ushort*)target->data(); - for (int i = len; i >=0; --i) - data[i] = (uchar) chars[i]; - } break; + qt_from_latin1((ushort*)target->data(), chars, len); + break; default: *target = c->toUnicode(chars, len, &state); } -- cgit v1.2.3