diff options
author | Paul Olav Tvete <paul.tvete@nokia.com> | 2010-10-27 07:40:38 (GMT) |
---|---|---|
committer | Paul Olav Tvete <paul.tvete@nokia.com> | 2010-10-27 07:40:38 (GMT) |
commit | e4feb707118947feea8568a82d57a8db6ae59410 (patch) | |
tree | ecf77b7d677f174b59e1c5110dd7aebee877f02d /src/corelib/tools | |
parent | 85f3f3ac74a2e7fe6a0874a46f9358a15f0dab34 (diff) | |
parent | 2925995de32f76a72fcdd7d577e609a68a517fa1 (diff) | |
download | Qt-e4feb707118947feea8568a82d57a8db6ae59410.zip Qt-e4feb707118947feea8568a82d57a8db6ae59410.tar.gz Qt-e4feb707118947feea8568a82d57a8db6ae59410.tar.bz2 |
Merge remote branch 'qt/master' into lighthouse-master
Conflicts:
src/corelib/global/qglobal.h
Diffstat (limited to 'src/corelib/tools')
-rw-r--r-- | src/corelib/tools/qstring.cpp | 30 |
1 files changed, 8 insertions, 22 deletions
diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp index 30ef9de..2737574 100644 --- a/src/corelib/tools/qstring.cpp +++ b/src/corelib/tools/qstring.cpp @@ -7460,31 +7460,17 @@ QDataStream &operator<<(QDataStream &out, const QString &str) out << str.toLatin1(); } else { if (!str.isNull() || out.version() < 3) { - int byteOrder = out.byteOrder(); - const QChar* ub = str.unicode(); - static const uint auto_size = 1024; - char t[auto_size]; - char *b; - if (str.length()*sizeof(QChar) > auto_size) { - b = new char[str.length()*sizeof(QChar)]; + if ((out.byteOrder() == QDataStream::BigEndian) == (QSysInfo::ByteOrder == QSysInfo::BigEndian)) { + out.writeBytes(reinterpret_cast<const char *>(str.unicode()), sizeof(QChar) * str.length()); } else { - b = t; - } - int l = str.length(); - char *c=b; - while (l--) { - if (byteOrder == QDataStream::BigEndian) { - *c++ = (char)ub->row(); - *c++ = (char)ub->cell(); - } else { - *c++ = (char)ub->cell(); - *c++ = (char)ub->row(); + QVarLengthArray<ushort> buffer(str.length()); + const ushort *data = reinterpret_cast<const ushort *>(str.constData()); + for (int i = 0; i < str.length(); i++) { + buffer[i] = qbswap(*data); + ++data; } - ub++; + out.writeBytes(reinterpret_cast<const char *>(buffer.data()), sizeof(ushort) * buffer.size()); } - out.writeBytes(b, sizeof(QChar)*str.length()); - if (str.length()*sizeof(QChar) > auto_size) - delete [] b; } else { // write null marker out << (quint32)0xffffffff; |