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 <lars.knoll@digia.com>
This commit is contained in:
parent
1704cecfac
commit
d7287f595a
@ -993,6 +993,8 @@ QString QTextDecoder::toUnicode(const char *chars, int len)
|
|||||||
return c->toUnicode(chars, len, &state);
|
return c->toUnicode(chars, len, &state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// in qstring.cpp:
|
||||||
|
void qt_from_latin1(ushort *dst, const char *str, size_t size);
|
||||||
|
|
||||||
/*! \overload
|
/*! \overload
|
||||||
|
|
||||||
@ -1005,12 +1007,10 @@ void QTextDecoder::toUnicode(QString *target, const char *chars, int len)
|
|||||||
case 106: // utf8
|
case 106: // utf8
|
||||||
static_cast<const QUtf8Codec*>(c)->convertToUnicode(target, chars, len, &state);
|
static_cast<const QUtf8Codec*>(c)->convertToUnicode(target, chars, len, &state);
|
||||||
break;
|
break;
|
||||||
case 4: { // latin1
|
case 4: // latin1
|
||||||
target->resize(len);
|
target->resize(len);
|
||||||
ushort *data = (ushort*)target->data();
|
qt_from_latin1((ushort*)target->data(), chars, len);
|
||||||
for (int i = len; i >=0; --i)
|
break;
|
||||||
data[i] = (uchar) chars[i];
|
|
||||||
} break;
|
|
||||||
default:
|
default:
|
||||||
*target = c->toUnicode(chars, len, &state);
|
*target = c->toUnicode(chars, len, &state);
|
||||||
}
|
}
|
||||||
|
@ -210,7 +210,7 @@ inline RetType UnrollTailLoop<0>::exec(int, RetType returnIfExited, Functor1, Fu
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// conversion between Latin 1 and UTF-16
|
// conversion between Latin 1 and UTF-16
|
||||||
static void qt_from_latin1(ushort *dst, const char *str, size_t size)
|
void qt_from_latin1(ushort *dst, const char *str, size_t size)
|
||||||
{
|
{
|
||||||
/* SIMD:
|
/* SIMD:
|
||||||
* Unpacking with SSE has been shown to improve performance on recent CPUs
|
* Unpacking with SSE has been shown to improve performance on recent CPUs
|
||||||
|
Loading…
x
Reference in New Issue
Block a user