summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQt Continuous Integration System <qt-info@nokia.com>2010-10-26 17:17:47 (GMT)
committerQt Continuous Integration System <qt-info@nokia.com>2010-10-26 17:17:47 (GMT)
commitc52ed680fddab0f41bbc050fd3992bfc1ddc4bff (patch)
treedb44c1ee93c635096dbfdc65ffe5d36431e2232e
parent906f30412793b741142c5b8ba28a351c54c22b42 (diff)
parenta17b650347a7aaafe75cd16bbd6029eac3260d77 (diff)
downloadQt-c52ed680fddab0f41bbc050fd3992bfc1ddc4bff.zip
Qt-c52ed680fddab0f41bbc050fd3992bfc1ddc4bff.tar.gz
Qt-c52ed680fddab0f41bbc050fd3992bfc1ddc4bff.tar.bz2
Merge branch 'master' of scm.dev.nokia.troll.no:qt/oslo-staging-2 into master-integration
* 'master' of scm.dev.nokia.troll.no:qt/oslo-staging-2: QDataStream: speedup steaming of QString by avoiding an unesessary copy.
-rw-r--r--src/corelib/tools/qstring.cpp30
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;